File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -151,4 +151,60 @@ describe('composeWithJson', () => {
151151 } ,
152152 } ) ;
153153 } ) ;
154+
155+ it ( 'check shallow objects' , async ( ) => {
156+ const restApiResponse = {
157+ title : 'A New Hope' ,
158+ producer : {
159+ name : 'Gary Kurtz, Rick McCallum' ,
160+ } ,
161+ } ;
162+
163+ const FilmTC = composeWithJson ( 'FilmCustom' , restApiResponse ) ;
164+
165+ expect ( FilmTC . getFieldTC ( 'producer' ) . getTypeName ( ) ) . toBe ( 'FilmCustom_Producer' ) ;
166+ expect ( FilmTC . getFieldTC ( 'producer' ) . getFieldNames ( ) ) . toEqual ( [ 'name' ] ) ;
167+ expect (
168+ FilmTC . getFieldTC ( 'producer' )
169+ . getFieldType ( 'name' )
170+ . toString ( )
171+ ) . toBe ( 'String' ) ;
172+
173+ const schema1 = new GraphQLSchema ( {
174+ query : new GraphQLObjectType ( {
175+ name : 'Query' ,
176+ fields : {
177+ film : {
178+ type : FilmTC . getType ( ) ,
179+ resolve : ( ) => {
180+ return restApiResponse ;
181+ } ,
182+ } ,
183+ } ,
184+ } ) ,
185+ } ) ;
186+
187+ const res = await graphql . graphql (
188+ schema1 ,
189+ `{
190+ film {
191+ title
192+ producer {
193+ name
194+ }
195+ }
196+ }`
197+ ) ;
198+
199+ expect ( res ) . toEqual ( {
200+ data : {
201+ film : {
202+ title : 'A New Hope' ,
203+ producer : {
204+ name : 'Gary Kurtz, Rick McCallum' ,
205+ } ,
206+ } ,
207+ } ,
208+ } ) ;
209+ } ) ;
154210} ) ;
You can’t perform that action at this time.
0 commit comments