@@ -149,32 +149,39 @@ export function createGraphQLSchema<TSource, TContext, TArgs>(
149
149
if ( Array . isArray ( spec ) ) {
150
150
// Convert all non-OAS 3 into OAS 3
151
151
Promise . all (
152
- spec . map ( ele => {
152
+ spec . map ( ( ele ) => {
153
153
return Oas3Tools . getValidOAS3 ( ele )
154
154
} )
155
- ) . then ( oass => {
156
- resolve (
157
- translateOpenAPIToGraphQL (
158
- oass ,
159
- options as InternalOptions < TSource , TContext , TArgs >
155
+ )
156
+ . then ( ( oass ) => {
157
+ resolve (
158
+ translateOpenAPIToGraphQL (
159
+ oass ,
160
+ options as InternalOptions < TSource , TContext , TArgs >
161
+ )
160
162
)
161
- )
162
- } )
163
+ } )
164
+ . catch ( ( error ) => {
165
+ reject ( error )
166
+ } )
163
167
} else {
164
168
/**
165
169
* Check if the spec is a valid OAS 3
166
170
* If the spec is OAS 2.0, attempt to translate it into 3, then try to
167
171
* translate the spec into a GraphQL schema
168
172
*/
169
-
170
- Oas3Tools . getValidOAS3 ( spec ) . then ( oas => {
171
- resolve (
172
- translateOpenAPIToGraphQL (
173
- [ oas ] ,
174
- options as InternalOptions < TSource , TContext , TArgs >
173
+ Oas3Tools . getValidOAS3 ( spec )
174
+ . then ( ( oas ) => {
175
+ resolve (
176
+ translateOpenAPIToGraphQL (
177
+ [ oas ] ,
178
+ options as InternalOptions < TSource , TContext , TArgs >
179
+ )
175
180
)
176
- )
177
- } )
181
+ } )
182
+ . catch ( ( error ) => {
183
+ reject ( error )
184
+ } )
178
185
}
179
186
} )
180
187
}
@@ -518,15 +525,15 @@ function translateOpenAPIToGraphQL<TSource, TContext, TArgs>(
518
525
mutationFields = sortObject ( mutationFields )
519
526
subscriptionFields = sortObject ( subscriptionFields )
520
527
authQueryFields = sortObject ( authQueryFields )
521
- Object . keys ( authQueryFields ) . forEach ( key => {
528
+ Object . keys ( authQueryFields ) . forEach ( ( key ) => {
522
529
authQueryFields [ key ] = sortObject ( authQueryFields [ key ] )
523
530
} )
524
531
authMutationFields = sortObject ( authMutationFields )
525
- Object . keys ( authMutationFields ) . forEach ( key => {
532
+ Object . keys ( authMutationFields ) . forEach ( ( key ) => {
526
533
authMutationFields [ key ] = sortObject ( authMutationFields [ key ] )
527
534
} )
528
535
authSubscriptionFields = sortObject ( authSubscriptionFields )
529
- Object . keys ( authSubscriptionFields ) . forEach ( key => {
536
+ Object . keys ( authSubscriptionFields ) . forEach ( ( key ) => {
530
537
authSubscriptionFields [ key ] = sortObject ( authSubscriptionFields [ key ] )
531
538
} )
532
539
@@ -719,13 +726,13 @@ function checkCustomResolversStructure<TSource, TContext, TArgs>(
719
726
if ( typeof customResolvers === 'object' ) {
720
727
// Check that all OASs that are referenced in the customResolvers are provided
721
728
Object . keys ( customResolvers )
722
- . filter ( title => {
729
+ . filter ( ( title ) => {
723
730
// If no OAS contains this title
724
- return ! data . oass . some ( oas => {
731
+ return ! data . oass . some ( ( oas ) => {
725
732
return title === oas . info . title
726
733
} )
727
734
} )
728
- . forEach ( title => {
735
+ . forEach ( ( title ) => {
729
736
handleWarning ( {
730
737
mitigationType : MitigationTypes . CUSTOM_RESOLVER_UNKNOWN_OAS ,
731
738
message :
@@ -737,16 +744,16 @@ function checkCustomResolversStructure<TSource, TContext, TArgs>(
737
744
} )
738
745
739
746
// TODO: Only run the following test on OASs that exist. See previous check.
740
- Object . keys ( customResolvers ) . forEach ( title => {
747
+ Object . keys ( customResolvers ) . forEach ( ( title ) => {
741
748
// Get all operations from a particular OAS
742
- const operations = Object . values ( data . operations ) . filter ( operation => {
749
+ const operations = Object . values ( data . operations ) . filter ( ( operation ) => {
743
750
return title === operation . oas . info . title
744
751
} )
745
752
746
- Object . keys ( customResolvers [ title ] ) . forEach ( path => {
747
- Object . keys ( customResolvers [ title ] [ path ] ) . forEach ( method => {
753
+ Object . keys ( customResolvers [ title ] ) . forEach ( ( path ) => {
754
+ Object . keys ( customResolvers [ title ] [ path ] ) . forEach ( ( method ) => {
748
755
if (
749
- ! operations . some ( operation => {
756
+ ! operations . some ( ( operation ) => {
750
757
return path === operation . path && method === operation . method
751
758
} )
752
759
) {
@@ -775,7 +782,7 @@ function preliminaryChecks<TSource, TContext, TArgs>(
775
782
data : PreprocessingData < TSource , TContext , TArgs >
776
783
) : void {
777
784
// Check if OASs have unique titles
778
- const titles = data . oass . map ( oas => {
785
+ const titles = data . oass . map ( ( oas ) => {
779
786
return oas . info . title
780
787
} )
781
788
@@ -784,7 +791,7 @@ function preliminaryChecks<TSource, TContext, TArgs>(
784
791
titles . filter ( ( title , index ) => {
785
792
return titles . indexOf ( title ) !== index
786
793
} )
787
- ) . forEach ( title => {
794
+ ) . forEach ( ( title ) => {
788
795
handleWarning ( {
789
796
mitigationType : MitigationTypes . MULTIPLE_OAS_SAME_TITLE ,
790
797
message : `Multiple OAS share the same title '${ title } '` ,
0 commit comments