Skip to content

Commit

Permalink
feat(core): Allow "enabled" state to be set when creating products
Browse files Browse the repository at this point in the history
Relates to #608
  • Loading branch information
michaelbromley committed Jan 8, 2021
1 parent eb9ad09 commit 02eb9f7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,7 @@ export type ProductTranslationInput = {

export type CreateProductInput = {
featuredAssetId?: Maybe<Scalars['ID']>;
enabled?: Maybe<Scalars['Boolean']>;
assetIds?: Maybe<Array<Scalars['ID']>>;
facetValueIds?: Maybe<Array<Scalars['ID']>>;
translations: Array<ProductTranslationInput>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,7 @@ export type ProductTranslationInput = {

export type CreateProductInput = {
featuredAssetId?: Maybe<Scalars['ID']>;
enabled?: Maybe<Scalars['Boolean']>;
assetIds?: Maybe<Array<Scalars['ID']>>;
facetValueIds?: Maybe<Array<Scalars['ID']>>;
translations: Array<ProductTranslationInput>;
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,7 @@ export type ProductTranslationInput = {

export type CreateProductInput = {
featuredAssetId?: Maybe<Scalars['ID']>;
enabled?: Maybe<Scalars['Boolean']>;
assetIds?: Maybe<Array<Scalars['ID']>>;
facetValueIds?: Maybe<Array<Scalars['ID']>>;
translations: Array<ProductTranslationInput>;
Expand Down
1 change: 1 addition & 0 deletions packages/core/e2e/graphql/generated-e2e-admin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,7 @@ export type ProductTranslationInput = {

export type CreateProductInput = {
featuredAssetId?: Maybe<Scalars['ID']>;
enabled?: Maybe<Scalars['Boolean']>;
assetIds?: Maybe<Array<Scalars['ID']>>;
facetValueIds?: Maybe<Array<Scalars['ID']>>;
translations: Array<ProductTranslationInput>;
Expand Down
21 changes: 21 additions & 0 deletions packages/core/e2e/product.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,27 @@ describe('Product resolver', () => {
newProductWithAssets = result.createProduct;
});

it('createProduct creates a disabled Product', async () => {
const result = await adminClient.query<CreateProduct.Mutation, CreateProduct.Variables>(
CREATE_PRODUCT,
{
input: {
enabled: false,
translations: [
{
languageCode: LanguageCode.en,
name: 'en Small apple',
slug: 'en-small-apple',
description: 'A small apple',
},
],
},
},
);
expect(result.createProduct.enabled).toBe(false);
newProduct = result.createProduct;
});

it('updateProduct updates a Product', async () => {
const result = await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(
UPDATE_PRODUCT,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/api/schema/admin-api/product.api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ input ProductTranslationInput {

input CreateProductInput {
featuredAssetId: ID
enabled: Boolean
assetIds: [ID!]
facetValueIds: [ID!]
translations: [ProductTranslationInput!]!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,7 @@ export type ProductTranslationInput = {

export type CreateProductInput = {
featuredAssetId?: Maybe<Scalars['ID']>;
enabled?: Maybe<Scalars['Boolean']>;
assetIds?: Maybe<Array<Scalars['ID']>>;
facetValueIds?: Maybe<Array<Scalars['ID']>>;
translations: Array<ProductTranslationInput>;
Expand Down
2 changes: 1 addition & 1 deletion schema-admin.json

Large diffs are not rendered by default.

0 comments on commit 02eb9f7

Please sign in to comment.