@@ -183,6 +183,10 @@ const customConfig = mergeConfig(testConfig(), {
183
183
readonly : true ,
184
184
} ,
185
185
] ,
186
+ Collection : [
187
+ { name : 'secretKey1' , type : 'string' , defaultValue : '' , public : false , internal : true } ,
188
+ { name : 'secretKey2' , type : 'string' , defaultValue : '' , public : false , internal : false } ,
189
+ ] ,
186
190
OrderLine : [ { name : 'validateInt' , type : 'int' , min : 0 , max : 10 } ] ,
187
191
} as CustomFields ,
188
192
} ) ;
@@ -942,6 +946,20 @@ describe('Custom fields', () => {
942
946
` ) ;
943
947
} , 'Cannot query field "internalString" on type "ProductCustomFields"' ) ,
944
948
) ;
949
+
950
+ // https://github.com/vendure-ecommerce/vendure/issues/3049
951
+ it ( 'does not leak private fields via JSON type' , async ( ) => {
952
+ const { collection } = await shopClient . query ( gql `
953
+ query {
954
+ collection(id: "T_1") {
955
+ id
956
+ customFields
957
+ }
958
+ }
959
+ ` ) ;
960
+
961
+ expect ( collection . customFields ) . toBe ( null ) ;
962
+ } ) ;
945
963
} ) ;
946
964
947
965
describe ( 'sort & filter' , ( ) => {
@@ -1087,18 +1105,16 @@ describe('Custom fields', () => {
1087
1105
1088
1106
describe ( 'unique constraint' , ( ) => {
1089
1107
it ( 'setting unique value works' , async ( ) => {
1090
- const result = await adminClient . query (
1091
- gql `
1092
- mutation {
1093
- updateProduct(input: { id: "T_1", customFields: { uniqueString: "foo" } }) {
1094
- id
1095
- customFields {
1096
- uniqueString
1097
- }
1108
+ const result = await adminClient . query ( gql `
1109
+ mutation {
1110
+ updateProduct(input: { id: "T_1", customFields: { uniqueString: "foo" } }) {
1111
+ id
1112
+ customFields {
1113
+ uniqueString
1098
1114
}
1099
1115
}
1100
- ` ,
1101
- ) ;
1116
+ }
1117
+ ` ) ;
1102
1118
1103
1119
expect ( result . updateProduct . customFields . uniqueString ) . toBe ( 'foo' ) ;
1104
1120
} ) ;
0 commit comments