File tree Expand file tree Collapse file tree 2 files changed +2
-16
lines changed
Expand file tree Collapse file tree 2 files changed +2
-16
lines changed Original file line number Diff line number Diff line change @@ -89,15 +89,7 @@ var droidData = {
8989 */
9090function getCharacter ( id ) {
9191 // Returning a promise just to illustrate GraphQL.js's support.
92- return new Promise ( resolve => {
93- if ( humanData [ id ] !== undefined ) {
94- return resolve ( humanData [ id ] ) ;
95- }
96- if ( droidData [ id ] !== undefined ) {
97- return resolve ( droidData [ id ] ) ;
98- }
99- return resolve ( null ) ;
100- } ) ;
92+ return Promise . resolve ( humanData [ id ] || droidData [ id ] ) ;
10193}
10294
10395/**
Original file line number Diff line number Diff line change @@ -127,13 +127,7 @@ var characterInterface = new GraphQLInterfaceType({
127127 } ,
128128 } ) ,
129129 resolveType : ( obj ) => {
130- if ( starWarsData . Humans [ obj . id ] !== undefined ) {
131- return humanType ;
132- }
133- if ( starWarsData . Droids [ obj . id ] !== undefined ) {
134- return droidType ;
135- }
136- return null ;
130+ return starWarsData . Humans [ obj . id ] ? humanType : droidType ;
137131 }
138132} ) ;
139133
You can’t perform that action at this time.
0 commit comments