Răsfoiți Sursa

feat(core): Add single facetValue create/update mutations to Admin API

Michael Bromley 5 luni în urmă
părinte
comite
4db0d518eb

+ 20 - 40
packages/common/src/generated-types.ts

@@ -2252,11 +2252,6 @@ export enum JobState {
   RUNNING = 'RUNNING'
   RUNNING = 'RUNNING'
 }
 }
 
 
-export type KeyValueInput = {
-  key: Scalars['String']['input'];
-  value: Scalars['JSON']['input'];
-};
-
 /**
 /**
  * @description
  * @description
  * Languages in the form of a ISO 639-1 language code with optional
  * Languages in the form of a ISO 639-1 language code with optional
@@ -2807,6 +2802,8 @@ export type Mutation = {
   createDraftOrder: Order;
   createDraftOrder: Order;
   /** Create a new Facet */
   /** Create a new Facet */
   createFacet: Facet;
   createFacet: Facet;
+  /** Create a single FacetValue */
+  createFacetValue: FacetValue;
   /** Create one or more FacetValues */
   /** Create one or more FacetValues */
   createFacetValues: Array<FacetValue>;
   createFacetValues: Array<FacetValue>;
   /** Create existing PaymentMethod */
   /** Create existing PaymentMethod */
@@ -2991,10 +2988,6 @@ export type Mutation = {
   setDraftOrderShippingAddress: Order;
   setDraftOrderShippingAddress: Order;
   /** Sets the shipping method by id, which can be obtained with the `eligibleShippingMethodsForDraftOrder` query */
   /** Sets the shipping method by id, which can be obtained with the `eligibleShippingMethodsForDraftOrder` query */
   setDraftOrderShippingMethod: SetOrderShippingMethodResult;
   setDraftOrderShippingMethod: SetOrderShippingMethodResult;
-  /** Set a single key-value pair (automatically scoped based on field configuration) */
-  setKeyValue: SetKeyValueResult;
-  /** Set multiple key-value pairs in a transaction (each automatically scoped) */
-  setKeyValues: Array<SetKeyValueResult>;
   setOrderCustomFields?: Maybe<Order>;
   setOrderCustomFields?: Maybe<Order>;
   /** Allows a different Customer to be assigned to an Order. Added in v2.2.0. */
   /** Allows a different Customer to be assigned to an Order. Added in v2.2.0. */
   setOrderCustomer?: Maybe<Order>;
   setOrderCustomer?: Maybe<Order>;
@@ -3032,6 +3025,8 @@ export type Mutation = {
   updateCustomerNote: HistoryEntry;
   updateCustomerNote: HistoryEntry;
   /** Update an existing Facet */
   /** Update an existing Facet */
   updateFacet: Facet;
   updateFacet: Facet;
+  /** Update a single FacetValue */
+  updateFacetValue: FacetValue;
   /** Update one or more FacetValues */
   /** Update one or more FacetValues */
   updateFacetValues: Array<FacetValue>;
   updateFacetValues: Array<FacetValue>;
   updateGlobalSettings: UpdateGlobalSettingsResult;
   updateGlobalSettings: UpdateGlobalSettingsResult;
@@ -3247,6 +3242,11 @@ export type MutationCreateFacetArgs = {
 };
 };
 
 
 
 
+export type MutationCreateFacetValueArgs = {
+  input: CreateFacetValueInput;
+};
+
+
 export type MutationCreateFacetValuesArgs = {
 export type MutationCreateFacetValuesArgs = {
   input: Array<CreateFacetValueInput>;
   input: Array<CreateFacetValueInput>;
 };
 };
@@ -3712,16 +3712,6 @@ export type MutationSetDraftOrderShippingMethodArgs = {
 };
 };
 
 
 
 
-export type MutationSetKeyValueArgs = {
-  input: KeyValueInput;
-};
-
-
-export type MutationSetKeyValuesArgs = {
-  inputs: Array<KeyValueInput>;
-};
-
-
 export type MutationSetOrderCustomFieldsArgs = {
 export type MutationSetOrderCustomFieldsArgs = {
   input: UpdateOrderInput;
   input: UpdateOrderInput;
 };
 };
@@ -3835,6 +3825,11 @@ export type MutationUpdateFacetArgs = {
 };
 };
 
 
 
 
+export type MutationUpdateFacetValueArgs = {
+  input: UpdateFacetValueInput;
+};
+
+
 export type MutationUpdateFacetValuesArgs = {
 export type MutationUpdateFacetValuesArgs = {
   input: Array<UpdateFacetValueInput>;
   input: Array<UpdateFacetValueInput>;
 };
 };
@@ -5153,14 +5148,11 @@ export type Query = {
   /** Returns all configured EntityDuplicators. */
   /** Returns all configured EntityDuplicators. */
   entityDuplicators: Array<EntityDuplicatorDefinition>;
   entityDuplicators: Array<EntityDuplicatorDefinition>;
   facet?: Maybe<Facet>;
   facet?: Maybe<Facet>;
+  facetValue?: Maybe<FacetValue>;
   facetValues: FacetValueList;
   facetValues: FacetValueList;
   facets: FacetList;
   facets: FacetList;
   fulfillmentHandlers: Array<ConfigurableOperationDefinition>;
   fulfillmentHandlers: Array<ConfigurableOperationDefinition>;
   /** Get value for a specific key (automatically scoped based on field configuration) */
   /** Get value for a specific key (automatically scoped based on field configuration) */
-  getKeyValue?: Maybe<Scalars['JSON']['output']>;
-  /** Get multiple key-value pairs (each automatically scoped) */
-  getKeyValues?: Maybe<Scalars['JSON']['output']>;
-  /** Get value for a specific key (automatically scoped based on field configuration) */
   getSettingsStoreValue?: Maybe<Scalars['JSON']['output']>;
   getSettingsStoreValue?: Maybe<Scalars['JSON']['output']>;
   /** Get multiple key-value pairs (each automatically scoped) */
   /** Get multiple key-value pairs (each automatically scoped) */
   getSettingsStoreValues?: Maybe<Scalars['JSON']['output']>;
   getSettingsStoreValues?: Maybe<Scalars['JSON']['output']>;
@@ -5304,6 +5296,11 @@ export type QueryFacetArgs = {
 };
 };
 
 
 
 
+export type QueryFacetValueArgs = {
+  id: Scalars['ID']['input'];
+};
+
+
 export type QueryFacetValuesArgs = {
 export type QueryFacetValuesArgs = {
   options?: InputMaybe<FacetValueListOptions>;
   options?: InputMaybe<FacetValueListOptions>;
 };
 };
@@ -5314,16 +5311,6 @@ export type QueryFacetsArgs = {
 };
 };
 
 
 
 
-export type QueryGetKeyValueArgs = {
-  key: Scalars['String']['input'];
-};
-
-
-export type QueryGetKeyValuesArgs = {
-  keys: Array<Scalars['String']['input']>;
-};
-
-
 export type QueryGetSettingsStoreValueArgs = {
 export type QueryGetSettingsStoreValueArgs = {
   key: Scalars['String']['input'];
   key: Scalars['String']['input'];
 };
 };
@@ -5921,13 +5908,6 @@ export type ServerConfig = {
 
 
 export type SetCustomerForDraftOrderResult = EmailAddressConflictError | Order;
 export type SetCustomerForDraftOrderResult = EmailAddressConflictError | Order;
 
 
-export type SetKeyValueResult = {
-  __typename?: 'SetKeyValueResult';
-  error?: Maybe<Scalars['String']['output']>;
-  key: Scalars['String']['output'];
-  result: Scalars['Boolean']['output'];
-};
-
 export type SetOrderCustomerInput = {
 export type SetOrderCustomerInput = {
   customerId: Scalars['ID']['input'];
   customerId: Scalars['ID']['input'];
   note?: InputMaybe<Scalars['String']['input']>;
   note?: InputMaybe<Scalars['String']['input']>;

+ 90 - 5
packages/core/e2e/facet.e2e-spec.ts

@@ -21,6 +21,7 @@ import {
     ASSIGN_PRODUCT_TO_CHANNEL,
     ASSIGN_PRODUCT_TO_CHANNEL,
     CREATE_CHANNEL,
     CREATE_CHANNEL,
     CREATE_FACET,
     CREATE_FACET,
+    CREATE_FACET_VALUE,
     GET_FACET_LIST,
     GET_FACET_LIST,
     GET_FACET_LIST_SIMPLE,
     GET_FACET_LIST_SIMPLE,
     GET_FACET_VALUE,
     GET_FACET_VALUE,
@@ -28,6 +29,7 @@ import {
     GET_FACET_WITH_VALUES,
     GET_FACET_WITH_VALUES,
     GET_PRODUCT_WITH_VARIANTS,
     GET_PRODUCT_WITH_VARIANTS,
     UPDATE_FACET,
     UPDATE_FACET,
+    UPDATE_FACET_VALUE,
     UPDATE_PRODUCT,
     UPDATE_PRODUCT,
     UPDATE_PRODUCT_VARIANTS,
     UPDATE_PRODUCT_VARIANTS,
 } from './graphql/shared-definitions';
 } from './graphql/shared-definitions';
@@ -146,6 +148,84 @@ describe('Facet resolver', () => {
         expect(result.updateFacetValues[0].code).toBe('compact');
         expect(result.updateFacetValues[0].code).toBe('compact');
     });
     });
 
 
+    it('createFacetValue (single)', async () => {
+        const result = await adminClient.query<
+            Codegen.CreateFacetValueMutation,
+            Codegen.CreateFacetValueMutationVariables
+        >(CREATE_FACET_VALUE, {
+            input: {
+                facetId: speakerTypeFacet.id,
+                code: 'wireless',
+                translations: [{ languageCode: LanguageCode.en, name: 'Wireless Speakers' }],
+            },
+        });
+
+        expect(result.createFacetValue).toEqual({
+            id: expect.any(String),
+            code: 'wireless',
+            name: 'Wireless Speakers',
+            languageCode: 'en',
+            facet: {
+                id: speakerTypeFacet.id,
+                name: 'Speaker Category',
+            },
+            translations: [
+                {
+                    id: expect.any(String),
+                    languageCode: LanguageCode.en,
+                    name: 'Wireless Speakers',
+                },
+            ],
+        });
+    });
+
+    it('updateFacetValue (single)', async () => {
+        // First get the newly created facet value
+        const facetWithValues = await adminClient.query<
+            Codegen.GetFacetWithValuesQuery,
+            Codegen.GetFacetWithValuesQueryVariables
+        >(GET_FACET_WITH_VALUES, {
+            id: speakerTypeFacet.id,
+        });
+
+        const wirelessFacetValue = facetWithValues.facet!.values.find(v => v.code === 'wireless')!;
+
+        const result = await adminClient.query<
+            Codegen.UpdateFacetValueMutation,
+            Codegen.UpdateFacetValueMutationVariables
+        >(UPDATE_FACET_VALUE, {
+            input: {
+                id: wirelessFacetValue.id,
+                code: 'bluetooth',
+                translations: [
+                    {
+                        id: wirelessFacetValue.translations[0].id,
+                        languageCode: LanguageCode.en,
+                        name: 'Bluetooth Speakers',
+                    },
+                ],
+            },
+        });
+
+        expect(result.updateFacetValue).toEqual({
+            id: wirelessFacetValue.id,
+            code: 'bluetooth',
+            name: 'Bluetooth Speakers',
+            languageCode: 'en',
+            facet: {
+                id: speakerTypeFacet.id,
+                name: 'Speaker Category',
+            },
+            translations: [
+                {
+                    id: expect.any(String),
+                    languageCode: LanguageCode.en,
+                    name: 'Bluetooth Speakers',
+                },
+            ],
+        });
+    });
+
     it('facets', async () => {
     it('facets', async () => {
         const result = await adminClient.query<Codegen.GetFacetListQuery>(GET_FACET_LIST);
         const result = await adminClient.query<Codegen.GetFacetListQuery>(GET_FACET_LIST);
 
 
@@ -181,7 +261,7 @@ describe('Facet resolver', () => {
         const result = await adminClient.query(GetFacetWithValueListDocument, {
         const result = await adminClient.query(GetFacetWithValueListDocument, {
             id: speakerTypeFacet.id,
             id: speakerTypeFacet.id,
         });
         });
-        expect(result.facet?.valueList.totalItems).toBe(3);
+        expect(result.facet?.valueList.totalItems).toBe(4);
     });
     });
 
 
     it('facet with valueList with name filter', async () => {
     it('facet with valueList with name filter', async () => {
@@ -195,7 +275,7 @@ describe('Facet resolver', () => {
                 },
                 },
             },
             },
         });
         });
-        expect(result.facet?.valueList.totalItems).toBe(2);
+        expect(result.facet?.valueList.totalItems).toBe(3);
     });
     });
 
 
     it('facetValues list query', async () => {
     it('facetValues list query', async () => {
@@ -210,9 +290,14 @@ describe('Facet resolver', () => {
             },
             },
         });
         });
 
 
-        expect(result.facetValues.totalItems).toBe(3);
-        expect(result.facetValues.items.length).toBe(3);
-        expect(result.facetValues.items.map(v => v.code).sort()).toEqual(['compact', 'hi-fi', 'pc']);
+        expect(result.facetValues.totalItems).toBe(4);
+        expect(result.facetValues.items.length).toBe(4);
+        expect(result.facetValues.items.map(v => v.code).sort()).toEqual([
+            'bluetooth',
+            'compact',
+            'hi-fi',
+            'pc',
+        ]);
         expect(result.facetValues.items.every(v => v.facet.id === speakerTypeFacet.id)).toBe(true);
         expect(result.facetValues.items.every(v => v.facet.id === speakerTypeFacet.id)).toBe(true);
     });
     });
 
 

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

@@ -2751,6 +2751,8 @@ export type Mutation = {
     createDraftOrder: Order;
     createDraftOrder: Order;
     /** Create a new Facet */
     /** Create a new Facet */
     createFacet: Facet;
     createFacet: Facet;
+    /** Create a single FacetValue */
+    createFacetValue: FacetValue;
     /** Create one or more FacetValues */
     /** Create one or more FacetValues */
     createFacetValues: Array<FacetValue>;
     createFacetValues: Array<FacetValue>;
     /** Create existing PaymentMethod */
     /** Create existing PaymentMethod */
@@ -2972,6 +2974,8 @@ export type Mutation = {
     updateCustomerNote: HistoryEntry;
     updateCustomerNote: HistoryEntry;
     /** Update an existing Facet */
     /** Update an existing Facet */
     updateFacet: Facet;
     updateFacet: Facet;
+    /** Update a single FacetValue */
+    updateFacetValue: FacetValue;
     /** Update one or more FacetValues */
     /** Update one or more FacetValues */
     updateFacetValues: Array<FacetValue>;
     updateFacetValues: Array<FacetValue>;
     updateGlobalSettings: UpdateGlobalSettingsResult;
     updateGlobalSettings: UpdateGlobalSettingsResult;
@@ -3153,6 +3157,10 @@ export type MutationCreateFacetArgs = {
     input: CreateFacetInput;
     input: CreateFacetInput;
 };
 };
 
 
+export type MutationCreateFacetValueArgs = {
+    input: CreateFacetValueInput;
+};
+
 export type MutationCreateFacetValuesArgs = {
 export type MutationCreateFacetValuesArgs = {
     input: Array<CreateFacetValueInput>;
     input: Array<CreateFacetValueInput>;
 };
 };
@@ -3620,6 +3628,10 @@ export type MutationUpdateFacetArgs = {
     input: UpdateFacetInput;
     input: UpdateFacetInput;
 };
 };
 
 
+export type MutationUpdateFacetValueArgs = {
+    input: UpdateFacetValueInput;
+};
+
 export type MutationUpdateFacetValuesArgs = {
 export type MutationUpdateFacetValuesArgs = {
     input: Array<UpdateFacetValueInput>;
     input: Array<UpdateFacetValueInput>;
 };
 };
@@ -9424,6 +9436,36 @@ export type UpdateFacetMutation = {
     };
     };
 };
 };
 
 
+export type CreateFacetValueMutationVariables = Exact<{
+    input: CreateFacetValueInput;
+}>;
+
+export type CreateFacetValueMutation = {
+    createFacetValue: {
+        id: string;
+        languageCode: LanguageCode;
+        code: string;
+        name: string;
+        translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+        facet: { id: string; name: string };
+    };
+};
+
+export type UpdateFacetValueMutationVariables = Exact<{
+    input: UpdateFacetValueInput;
+}>;
+
+export type UpdateFacetValueMutation = {
+    updateFacetValue: {
+        id: string;
+        languageCode: LanguageCode;
+        code: string;
+        name: string;
+        translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+        facet: { id: string; name: string };
+    };
+};
+
 export type GetCustomerListQueryVariables = Exact<{
 export type GetCustomerListQueryVariables = Exact<{
     options?: InputMaybe<CustomerListOptions>;
     options?: InputMaybe<CustomerListOptions>;
 }>;
 }>;
@@ -25786,6 +25828,164 @@ export const UpdateFacetDocument = {
         },
         },
     ],
     ],
 } as unknown as DocumentNode<UpdateFacetMutation, UpdateFacetMutationVariables>;
 } as unknown as DocumentNode<UpdateFacetMutation, UpdateFacetMutationVariables>;
+export const CreateFacetValueDocument = {
+    kind: 'Document',
+    definitions: [
+        {
+            kind: 'OperationDefinition',
+            operation: 'mutation',
+            name: { kind: 'Name', value: 'CreateFacetValue' },
+            variableDefinitions: [
+                {
+                    kind: 'VariableDefinition',
+                    variable: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
+                    type: {
+                        kind: 'NonNullType',
+                        type: { kind: 'NamedType', name: { kind: 'Name', value: 'CreateFacetValueInput' } },
+                    },
+                },
+            ],
+            selectionSet: {
+                kind: 'SelectionSet',
+                selections: [
+                    {
+                        kind: 'Field',
+                        name: { kind: 'Name', value: 'createFacetValue' },
+                        arguments: [
+                            {
+                                kind: 'Argument',
+                                name: { kind: 'Name', value: 'input' },
+                                value: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
+                            },
+                        ],
+                        selectionSet: {
+                            kind: 'SelectionSet',
+                            selections: [
+                                { kind: 'FragmentSpread', name: { kind: 'Name', value: 'FacetValue' } },
+                            ],
+                        },
+                    },
+                ],
+            },
+        },
+        {
+            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<CreateFacetValueMutation, CreateFacetValueMutationVariables>;
+export const UpdateFacetValueDocument = {
+    kind: 'Document',
+    definitions: [
+        {
+            kind: 'OperationDefinition',
+            operation: 'mutation',
+            name: { kind: 'Name', value: 'UpdateFacetValue' },
+            variableDefinitions: [
+                {
+                    kind: 'VariableDefinition',
+                    variable: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
+                    type: {
+                        kind: 'NonNullType',
+                        type: { kind: 'NamedType', name: { kind: 'Name', value: 'UpdateFacetValueInput' } },
+                    },
+                },
+            ],
+            selectionSet: {
+                kind: 'SelectionSet',
+                selections: [
+                    {
+                        kind: 'Field',
+                        name: { kind: 'Name', value: 'updateFacetValue' },
+                        arguments: [
+                            {
+                                kind: 'Argument',
+                                name: { kind: 'Name', value: 'input' },
+                                value: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
+                            },
+                        ],
+                        selectionSet: {
+                            kind: 'SelectionSet',
+                            selections: [
+                                { kind: 'FragmentSpread', name: { kind: 'Name', value: 'FacetValue' } },
+                            ],
+                        },
+                    },
+                ],
+            },
+        },
+        {
+            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<UpdateFacetValueMutation, UpdateFacetValueMutationVariables>;
 export const GetCustomerListDocument = {
 export const GetCustomerListDocument = {
     kind: 'Document',
     kind: 'Document',
     definitions: [
     definitions: [

+ 18 - 0
packages/core/e2e/graphql/shared-definitions.ts

@@ -126,6 +126,24 @@ export const UPDATE_FACET = gql`
     ${FACET_WITH_VALUES_FRAGMENT}
     ${FACET_WITH_VALUES_FRAGMENT}
 `;
 `;
 
 
+export const CREATE_FACET_VALUE = gql`
+    mutation CreateFacetValue($input: CreateFacetValueInput!) {
+        createFacetValue(input: $input) {
+            ...FacetValue
+        }
+    }
+    ${FACET_VALUE_FRAGMENT}
+`;
+
+export const UPDATE_FACET_VALUE = gql`
+    mutation UpdateFacetValue($input: UpdateFacetValueInput!) {
+        updateFacetValue(input: $input) {
+            ...FacetValue
+        }
+    }
+    ${FACET_VALUE_FRAGMENT}
+`;
+
 export const GET_CUSTOMER_LIST = gql`
 export const GET_CUSTOMER_LIST = gql`
     query GetCustomerList($options: CustomerListOptions) {
     query GetCustomerList($options: CustomerListOptions) {
         customers(options: $options) {
         customers(options: $options) {

+ 28 - 0
packages/core/src/api/resolvers/admin/facet.resolver.ts

@@ -3,12 +3,14 @@ import {
     DeletionResponse,
     DeletionResponse,
     MutationAssignFacetsToChannelArgs,
     MutationAssignFacetsToChannelArgs,
     MutationCreateFacetArgs,
     MutationCreateFacetArgs,
+    MutationCreateFacetValueArgs,
     MutationCreateFacetValuesArgs,
     MutationCreateFacetValuesArgs,
     MutationDeleteFacetArgs,
     MutationDeleteFacetArgs,
     MutationDeleteFacetsArgs,
     MutationDeleteFacetsArgs,
     MutationDeleteFacetValuesArgs,
     MutationDeleteFacetValuesArgs,
     MutationRemoveFacetsFromChannelArgs,
     MutationRemoveFacetsFromChannelArgs,
     MutationUpdateFacetArgs,
     MutationUpdateFacetArgs,
+    MutationUpdateFacetValueArgs,
     MutationUpdateFacetValuesArgs,
     MutationUpdateFacetValuesArgs,
     Permission,
     Permission,
     QueryFacetArgs,
     QueryFacetArgs,
@@ -151,6 +153,21 @@ export class FacetResolver {
         return facetValues;
         return facetValues;
     }
     }
 
 
+    @Transaction()
+    @Mutation()
+    @Allow(Permission.CreateCatalog, Permission.CreateFacet)
+    async createFacetValue(
+        @Ctx() ctx: RequestContext,
+        @Args() args: MutationCreateFacetValueArgs,
+    ): Promise<Translated<FacetValue>> {
+        const { input } = args;
+        const facet = await this.facetService.findOne(ctx, input.facetId);
+        if (!facet) {
+            throw new EntityNotFoundError('Facet', input.facetId);
+        }
+        return this.facetValueService.create(ctx, facet, input);
+    }
+
     @Transaction()
     @Transaction()
     @Mutation()
     @Mutation()
     @Allow(Permission.UpdateCatalog, Permission.UpdateFacet)
     @Allow(Permission.UpdateCatalog, Permission.UpdateFacet)
@@ -162,6 +179,17 @@ export class FacetResolver {
         return Promise.all(input.map(facetValue => this.facetValueService.update(ctx, facetValue)));
         return Promise.all(input.map(facetValue => this.facetValueService.update(ctx, facetValue)));
     }
     }
 
 
+    @Transaction()
+    @Mutation()
+    @Allow(Permission.UpdateCatalog, Permission.UpdateFacet)
+    async updateFacetValue(
+        @Ctx() ctx: RequestContext,
+        @Args() args: MutationUpdateFacetValueArgs,
+    ): Promise<Translated<FacetValue>> {
+        const { input } = args;
+        return this.facetValueService.update(ctx, input);
+    }
+
     @Transaction()
     @Transaction()
     @Mutation()
     @Mutation()
     @Allow(Permission.DeleteCatalog, Permission.DeleteFacet)
     @Allow(Permission.DeleteCatalog, Permission.DeleteFacet)

+ 6 - 0
packages/core/src/api/schema/admin-api/facet.api.graphql

@@ -21,9 +21,15 @@ type Mutation {
     "Create one or more FacetValues"
     "Create one or more FacetValues"
     createFacetValues(input: [CreateFacetValueInput!]!): [FacetValue!]!
     createFacetValues(input: [CreateFacetValueInput!]!): [FacetValue!]!
 
 
+    "Create a single FacetValue"
+    createFacetValue(input: CreateFacetValueInput!): FacetValue!
+
     "Update one or more FacetValues"
     "Update one or more FacetValues"
     updateFacetValues(input: [UpdateFacetValueInput!]!): [FacetValue!]!
     updateFacetValues(input: [UpdateFacetValueInput!]!): [FacetValue!]!
 
 
+    "Update a single FacetValue"
+    updateFacetValue(input: UpdateFacetValueInput!): FacetValue!
+
     "Delete one or more FacetValues"
     "Delete one or more FacetValues"
     deleteFacetValues(ids: [ID!]!, force: Boolean): [DeletionResponse!]!
     deleteFacetValues(ids: [ID!]!, force: Boolean): [DeletionResponse!]!
 
 

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
schema-admin.json


Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff