File tree 3 files changed +64
-0
lines changed
3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,22 @@ export default buildConfigWithDefaults({
84
84
type : 'relationship' ,
85
85
relationTo : relationSlug ,
86
86
} ,
87
+ {
88
+ name : 'blocks' ,
89
+ type : 'blocks' ,
90
+ blocks : [
91
+ {
92
+ slug : 'block' ,
93
+ fields : [
94
+ {
95
+ name : 'relationField' ,
96
+ type : 'relationship' ,
97
+ relationTo : relationSlug ,
98
+ } ,
99
+ ] ,
100
+ } ,
101
+ ] ,
102
+ } ,
87
103
// Relationship w/ default access
88
104
{
89
105
name : 'defaultAccessRelation' ,
Original file line number Diff line number Diff line change @@ -334,6 +334,35 @@ describe('Relationships', () => {
334
334
expect ( query . docs ) . toHaveLength ( 1 ) // Due to limit: 1
335
335
} )
336
336
337
+ it ( 'should allow querying within blocks' , async ( ) => {
338
+ const rel = await payload . create ( {
339
+ collection : relationSlug ,
340
+ data : {
341
+ name : 'test' ,
342
+ disableRelation : false ,
343
+ } ,
344
+ } )
345
+
346
+ const doc = await payload . create ( {
347
+ collection : slug ,
348
+ data : {
349
+ blocks : [
350
+ {
351
+ blockType : 'block' ,
352
+ relationField : rel . id ,
353
+ } ,
354
+ ] ,
355
+ } ,
356
+ } )
357
+
358
+ const { docs } = await payload . find ( {
359
+ collection : slug ,
360
+ where : { 'blocks.relationField' : { equals : rel . id } } ,
361
+ } )
362
+
363
+ expect ( docs [ 0 ] . id ) . toBe ( doc . id )
364
+ } )
365
+
337
366
describe ( 'Custom ID' , ( ) => {
338
367
it ( 'should query a custom id relation' , async ( ) => {
339
368
const { customIdRelation } = await restClient
Original file line number Diff line number Diff line change @@ -97,6 +97,14 @@ export interface Post {
97
97
description ?: string | null ;
98
98
number ?: number | null ;
99
99
relationField ?: ( string | null ) | Relation ;
100
+ blocks ?:
101
+ | {
102
+ relationField ?: ( string | null ) | Relation ;
103
+ id ?: string | null ;
104
+ blockName ?: string | null ;
105
+ blockType : 'block' ;
106
+ } [ ]
107
+ | null ;
100
108
defaultAccessRelation ?: ( string | null ) | StrictAccess ;
101
109
chainedRelation ?: ( string | null ) | Chained ;
102
110
maxDepthRelation ?: ( string | null ) | Relation ;
@@ -429,6 +437,17 @@ export interface PostsSelect<T extends boolean = true> {
429
437
description ?: T ;
430
438
number ?: T ;
431
439
relationField ?: T ;
440
+ blocks ?:
441
+ | T
442
+ | {
443
+ block ?:
444
+ | T
445
+ | {
446
+ relationField ?: T ;
447
+ id ?: T ;
448
+ blockName ?: T ;
449
+ } ;
450
+ } ;
432
451
defaultAccessRelation ?: T ;
433
452
chainedRelation ?: T ;
434
453
maxDepthRelation ?: T ;
You can’t perform that action at this time.
0 commit comments