You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the ProductGroupOption, I can give it an CreateProductOptionGroupInput, this has the property to add options: CreateGroupOptionInput but these are not added in the db?
To Reproduce
Here is the script:
import {INestApplicationContext} from '@nestjs/common';
import {
bootstrapWorker,
ConfigService,
FacetService,
FacetValueService, LanguageCode, ProductOptionGroupService, ProductOptionService,
RequestContext,
RequestContextService,
TransactionalConnection,
User,
} from '@vendure/core';
import path from 'path';
import 'reflect-metadata';
import { config } from '../vendure-config';
if (require.main === module) {
importDataInitialData().then(
() => process.exit(0),
err => {
console.log(err);
process.exit(1);
},
);
}
export type InputMaybe<T> = T;
export type Scalars = {
ID: { input: string; output: string; }
String: { input: string; output: string; }
Boolean: { input: boolean; output: boolean; }
Int: { input: number; output: number; }
Float: { input: number; output: number; }
DateTime: { input: Date; output: string; }
JSON: { input: any; output: any; }
Money: { input: number; output: number; }
Upload: { input: any; output: any; }
};
export type CreateGroupOptionInput = {
code: Scalars['String']['input'];
translations: Array<ProductOptionGroupTranslationInput>;
};
export type ProductOptionGroupTranslationInput = {
customFields?: InputMaybe<Scalars['JSON']['input']>;
id?: InputMaybe<Scalars['ID']['input']>;
languageCode: LanguageCode;
name?: InputMaybe<Scalars['String']['input']>;
};
export type CreateProductOptionGroupInput = {
code: Scalars['String']['input'];
customFields?: InputMaybe<Scalars['JSON']['input']>;
options: Array<CreateGroupOptionInput>;
translations: Array<ProductOptionGroupTranslationInput>;
};
async function importDataInitialData() {
// We use the bootstrapWorker() function instead of bootstrap() because we don't
// need to start the server, we just need access to the services.
const {app} = await bootstrapWorker(config);
// Let's grab a reference to each of the Vendure services we'll need.
const productGroupOptionService = app.get(ProductOptionGroupService);
// Most service methods require a RequestContext, so we'll create one here.
const ctx = await getSuperadminContext(app);
const productOptionInput: CreateProductOptionGroupInput = {
code: 'productOptions',
options: [{
code: 'option1',
translations: [
{ languageCode: LanguageCode.en, name: 'option1' }
],
},
{
code: 'option2',
translations: [
{ languageCode: LanguageCode.en, name: 'option2' }
],
}],
translations: [
{ languageCode: LanguageCode.en, name: 'productOptions' }
],
};
const value = await productGroupOptionService.create(ctx, productOptionInput);
// Close the app
await app.close();
}
/**
* Creates a RequestContext configured for the default Channel with the activeUser set
* as the superadmin user.
*/
export async function getSuperadminContext(app: INestApplicationContext): Promise<RequestContext> {
const {superadminCredentials} = app.get(ConfigService).authOptions;
const superAdminUser = await app
.get(TransactionalConnection)
.rawConnection.getRepository(User)
.findOneOrFail({where: {identifier: superadminCredentials.identifier}});
return app.get(RequestContextService).create({
apiType: 'admin',
user: superAdminUser,
});
}
Expected behavior
CreateGroupOptionInput should be save!
Environment (please complete the following information):
@vendure/core version: 2.1.4
Nodejs version: 20.10.0
Database (mysql/postgres etc): Postgres
Additional context
This is run through a CLI script.
Codgen generates these things:
ProductOptionGroupInput
has options CreateGroupOptionInput (2)
has translations ProductOptionGroupTranslationInput (1)
CreateGroupOptionInput (2 - Should it not be a ProductOption (instead of GroupOption)?)
has translations ProductOptionGroupTranslationInput (1 - should this not be a seperate translation?)
These are used for ProductGroupOptionService.create(ctx, ProductOptionGroupInput)
This is not used:
CreateProductOptionInput
The text was updated successfully, but these errors were encountered:
Yes, you are right - the options don't get saved by that method. If you look at the createProductOptionGroup resolver you'll see that you actually have to call productOptionService.create for each option.
Describe the bug
When using the ProductGroupOption, I can give it an CreateProductOptionGroupInput, this has the property to add options:
CreateGroupOptionInput but these are not added in the db?
To Reproduce
Here is the script:
Expected behavior
CreateGroupOptionInput should be save!
Environment (please complete the following information):
Additional context
This is run through a CLI script.
Codgen generates these things:
ProductOptionGroupInput
CreateGroupOptionInput (2 - Should it not be a ProductOption (instead of GroupOption)?)
These are used for ProductGroupOptionService.create(ctx, ProductOptionGroupInput)
This is not used:
CreateProductOptionInput
The text was updated successfully, but these errors were encountered: