Remove singular/plural from field-metadata (#2085)
* Remove singular/plural from field-metadata * revert removing id from create input * remove console log * remove console log * codegen * missing files * fix tests
This commit is contained in:
@ -30,12 +30,12 @@ describe('generateCreateInputType', () => {
|
||||
test('should generate fields with correct types and descriptions', () => {
|
||||
const columns = [
|
||||
{
|
||||
nameSingular: 'firstName',
|
||||
name: 'firstName',
|
||||
type: 'text',
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
nameSingular: 'age',
|
||||
name: 'age',
|
||||
type: 'number',
|
||||
isNullable: true,
|
||||
},
|
||||
|
||||
@ -46,12 +46,12 @@ describe('generateObjectType', () => {
|
||||
test('should generate fields based on provided columns', () => {
|
||||
const columns = [
|
||||
{
|
||||
nameSingular: 'firstName',
|
||||
name: 'firstName',
|
||||
type: 'text',
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
nameSingular: 'age',
|
||||
name: 'age',
|
||||
type: 'number',
|
||||
isNullable: true,
|
||||
},
|
||||
|
||||
@ -29,12 +29,12 @@ describe('generateUpdateInputType', () => {
|
||||
test('should generate fields with correct types and descriptions', () => {
|
||||
const columns = [
|
||||
{
|
||||
nameSingular: 'firstName',
|
||||
name: 'firstName',
|
||||
type: 'text',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
nameSingular: 'age',
|
||||
name: 'age',
|
||||
type: 'number',
|
||||
isNullable: true,
|
||||
},
|
||||
|
||||
@ -40,7 +40,7 @@ describe('mapColumnTypeToGraphQLType', () => {
|
||||
test('should create a GraphQLEnumType for enum fields', () => {
|
||||
const column = new FieldMetadata();
|
||||
column.type = 'enum';
|
||||
column.nameSingular = 'Status';
|
||||
column.name = 'Status';
|
||||
column.enums = ['ACTIVE', 'INACTIVE'];
|
||||
const result = mapColumnTypeToGraphQLType(column);
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ export const generateCreateInputType = (
|
||||
columns.forEach((column) => {
|
||||
const graphqlType = mapColumnTypeToGraphQLType(column, true);
|
||||
|
||||
fields[column.nameSingular] = {
|
||||
fields[column.name] = {
|
||||
type: !column.isNullable ? new GraphQLNonNull(graphqlType) : graphqlType,
|
||||
};
|
||||
});
|
||||
|
||||
@ -33,7 +33,7 @@ export const generateObjectType = <TSource = any, TContext = any>(
|
||||
columns.forEach((column) => {
|
||||
const graphqlType = mapColumnTypeToGraphQLType(column);
|
||||
|
||||
fields[column.nameSingular] = {
|
||||
fields[column.name] = {
|
||||
type: !column.isNullable ? new GraphQLNonNull(graphqlType) : graphqlType,
|
||||
};
|
||||
});
|
||||
|
||||
@ -22,7 +22,7 @@ export const generateUpdateInputType = (
|
||||
columns.forEach((column) => {
|
||||
const graphqlType = mapColumnTypeToGraphQLType(column, true);
|
||||
// No GraphQLNonNull wrapping here, so all fields are optional
|
||||
fields[column.nameSingular] = {
|
||||
fields[column.name] = {
|
||||
type: graphqlType,
|
||||
};
|
||||
});
|
||||
|
||||
@ -65,7 +65,7 @@ export const mapColumnTypeToGraphQLType = (
|
||||
return GraphQLInt;
|
||||
case 'enum': {
|
||||
if (column.enums && column.enums.length > 0) {
|
||||
const enumName = `${pascalCase(column.nameSingular)}Enum`;
|
||||
const enumName = `${pascalCase(column.name)}Enum`;
|
||||
|
||||
return new GraphQLEnumType({
|
||||
name: enumName,
|
||||
|
||||
Reference in New Issue
Block a user