Skip to content

Commit

Permalink
Fix printSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Feb 3, 2023
1 parent 694c73d commit 6f25937
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/utilities/printSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,23 @@ function printSchemaDefinition(schema: GraphQLSchema): Maybe<string> {
* }
* ```
*
* When using this naming convention, the schema description can be omitted.
* When using this naming convention, the schema description can be omitted so
* long as these names are only used for operation types.
*/
function isSchemaOfCommonNames(schema: GraphQLSchema): boolean {
const queryType = schema.getQueryType();
if (queryType && queryType.name !== 'Query') {
return false;
}
const queryOperationType = schema.getQueryType() || null;
const mutationOperationType = schema.getMutationType() || null;
const subscriptionOperationType = schema.getSubscriptionType() || null;

const mutationType = schema.getMutationType();
if (mutationType && mutationType.name !== 'Mutation') {
return false;
}
const queryType = schema.getType('Query') || null;
const mutationType = schema.getType('Mutation') || null;
const subscriptionType = schema.getType('Subscription') || null;

const subscriptionType = schema.getSubscriptionType();
if (subscriptionType && subscriptionType.name !== 'Subscription') {
return false;
}

return true;
return (
queryOperationType === queryType &&
mutationOperationType === mutationType &&
subscriptionOperationType === subscriptionType
);
}

export function printType(type: GraphQLNamedType): string {
Expand Down

0 comments on commit 6f25937

Please sign in to comment.