File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -107,25 +107,23 @@ function printSchemaDefinition(schema: GraphQLSchema): Maybe<string> {
107
107
* }
108
108
* ```
109
109
*
110
- * When using this naming convention, the schema description can be omitted.
110
+ * When using this naming convention, the schema description can be omitted so
111
+ * long as these names are only used for operation types.
111
112
*/
112
113
function isSchemaOfCommonNames ( schema : GraphQLSchema ) : boolean {
113
- const queryType = schema . getQueryType ( ) ;
114
- if ( queryType && queryType . name !== 'Query' ) {
115
- return false ;
116
- }
114
+ const queryOperationType = schema . getQueryType ( ) || null ;
115
+ const mutationOperationType = schema . getMutationType ( ) || null ;
116
+ const subscriptionOperationType = schema . getSubscriptionType ( ) || null ;
117
117
118
- const mutationType = schema . getMutationType ( ) ;
119
- if ( mutationType && mutationType . name !== 'Mutation' ) {
120
- return false ;
121
- }
118
+ const queryType = schema . getType ( 'Query' ) || null ;
119
+ const mutationType = schema . getType ( 'Mutation' ) || null ;
120
+ const subscriptionType = schema . getType ( 'Subscription' ) || null ;
122
121
123
- const subscriptionType = schema . getSubscriptionType ( ) ;
124
- if ( subscriptionType && subscriptionType . name !== 'Subscription' ) {
125
- return false ;
126
- }
127
-
128
- return true ;
122
+ return (
123
+ queryOperationType === queryType &&
124
+ mutationOperationType === mutationType &&
125
+ subscriptionOperationType === subscriptionType
126
+ ) ;
129
127
}
130
128
131
129
export function printType ( type : GraphQLNamedType ) : string {
You can’t perform that action at this time.
0 commit comments