Skip to content

Commit

Permalink
fix(core): Correctly return custom field relation scalar fields
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Feb 26, 2024
1 parent fea6754 commit 1280cf3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
46 changes: 44 additions & 2 deletions packages/core/e2e/custom-fields.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ describe('Custom fields', () => {
type
list
}
... on RelationCustomFieldConfig {
scalarFields
}
}
}
}
Expand All @@ -241,7 +244,25 @@ describe('Custom fields', () => {
{ name: 'validateFn2', type: 'string', list: false },
{ name: 'validateFn3', type: 'string', list: false },
{ name: 'validateFn4', type: 'string', list: false },
{ name: 'validateRelation', type: 'relation', list: false },
{
name: 'validateRelation',
type: 'relation',
list: false,
scalarFields: [
'id',
'createdAt',
'updatedAt',
'name',
'type',
'fileSize',
'mimeType',
'width',
'height',
'source',
'preview',
'customFields',
],
},
{ name: 'stringWithOptions', type: 'string', list: false },
{ name: 'nullableStringWithOptions', type: 'string', list: false },
{ name: 'nonPublic', type: 'string', list: false },
Expand Down Expand Up @@ -273,6 +294,9 @@ describe('Custom fields', () => {
type
list
}
... on RelationCustomFieldConfig {
scalarFields
}
}
}
}
Expand Down Expand Up @@ -303,7 +327,25 @@ describe('Custom fields', () => {
{ name: 'validateFn2', type: 'string', list: false },
{ name: 'validateFn3', type: 'string', list: false },
{ name: 'validateFn4', type: 'string', list: false },
{ name: 'validateRelation', type: 'relation', list: false },
{
name: 'validateRelation',
type: 'relation',
list: false,
scalarFields: [
'id',
'createdAt',
'updatedAt',
'name',
'type',
'fileSize',
'mimeType',
'width',
'height',
'source',
'preview',
'customFields',
],
},
{ name: 'stringWithOptions', type: 'string', list: false },
{ name: 'nullableStringWithOptions', type: 'string', list: false },
{ name: 'nonPublic', type: 'string', list: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class GlobalSettingsResolver {
.map(c => {
// In the VendureConfig, the relation entity is specified
// as the class, but the GraphQL API exposes it as a string.
const customFieldConfig: GraphQLCustomFieldConfig = c as any;
const customFieldConfig: GraphQLCustomFieldConfig = { ...c } as any;
if (this.isRelationGraphQLType(customFieldConfig) && this.isRelationConfigType(c)) {
customFieldConfig.entity = c.entity.name;
customFieldConfig.scalarFields = this.getScalarFieldsOfType(
Expand Down

0 comments on commit 1280cf3

Please sign in to comment.