@@ -15,6 +15,7 @@ import PeopleRoomsCustomIdSeparator from './people-rooms-custom-id-separator'
1515import Company from './company'
1616import { Model } from 'objection'
1717import Employee from './employee'
18+ import Client from './client'
1819
1920const db = knex ( {
2021 client : 'sqlite3' ,
@@ -68,7 +69,7 @@ const app = feathers()
6869 model : Company ,
6970 id : 'id' ,
7071 events : [ 'testing' ] ,
71- allowedEager : 'ceos' ,
72+ allowedEager : '[ ceos, clients] ' ,
7273 namedEagerFilters : {
7374 notSnoop ( builder ) {
7475 return builder . whereNot ( 'name' , 'Snoop' )
@@ -81,7 +82,8 @@ const app = feathers()
8182 return builder . where ( 'age' , '<' , '25' )
8283 }
8384 }
84- ]
85+ ] ,
86+ allowedInsert : 'clients'
8587 } )
8688 )
8789 . use (
@@ -91,6 +93,13 @@ const app = feathers()
9193 allowedEager : 'company'
9294 } )
9395 )
96+ . use (
97+ '/clients' ,
98+ service ( {
99+ model : Client ,
100+ allowedEager : 'company'
101+ } )
102+ )
94103
95104let people = app . service ( 'people' )
96105let peopleRooms = app . service ( 'people-rooms' )
@@ -158,6 +167,16 @@ function clean (done) {
158167 table . integer ( 'companyId' ) . references ( 'companies.id' )
159168 table . string ( 'name' )
160169 } )
170+ } )
171+ } )
172+ . then ( ( ) => {
173+ return db . schema . dropTableIfExists ( 'clients' ) . then ( ( ) => {
174+ return db . schema
175+ . createTable ( 'clients' , table => {
176+ table . increments ( 'id' )
177+ table . integer ( 'companyId' ) . references ( 'companies.id' )
178+ table . string ( 'name' )
179+ } )
161180 . then ( ( ) => done ( ) )
162181 } )
163182 } )
@@ -457,6 +476,36 @@ describe('Feathers Objection Service', () => {
457476 } )
458477 } )
459478
479+ describe ( 'Graph Insert Queries' , ( ) => {
480+ before ( async ( ) => {
481+ await companies . remove ( null )
482+ await companies
483+ . create ( [
484+ {
485+ name : 'Google' ,
486+ clients : [
487+ {
488+ name : 'Dan Davis'
489+ } ,
490+ {
491+ name : 'Ken Patrick'
492+ }
493+ ]
494+ } ,
495+ {
496+ name : 'Apple'
497+ }
498+ ] )
499+ } )
500+
501+ it ( 'allows insertGraph queries' , ( ) => {
502+ return companies . find ( { query : { $eager : 'clients' } } ) . then ( data => {
503+ expect ( data [ 0 ] . clients ) . to . be . an ( 'array' )
504+ expect ( data [ 0 ] . clients ) . to . have . lengthOf ( 2 )
505+ } )
506+ } )
507+ } )
508+
460509 describe ( '$like method' , ( ) => {
461510 beforeEach ( async ( ) => {
462511 await people
0 commit comments