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
michaelbromley committed Feb 26, 2024

Verified

This commit was signed with the committer’s verified signature.
rouault Even Rouault
1 parent fea6754 commit 1280cf3
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
@@ -215,6 +215,9 @@ describe('Custom fields', () => {
type
list
}
... on RelationCustomFieldConfig {
scalarFields
}
}
}
}
@@ -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 },
@@ -273,6 +294,9 @@ describe('Custom fields', () => {
type
list
}
... on RelationCustomFieldConfig {
scalarFields
}
}
}
}
@@ -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 },
Original file line number Diff line number Diff line change
@@ -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(

0 comments on commit 1280cf3

Please sign in to comment.