isSchemaOfCommonNames method

bool isSchemaOfCommonNames(
  1. GraphQLSchema schema
)

GraphQL schema define root types for each type of operation. These types are the same as any other type and can be named in any manner, however there is a common naming convention:

schema { query: Query mutation: Mutation subscription: Subscription }

When using this naming convention, the schema description can be omitted.

Implementation

bool isSchemaOfCommonNames(GraphQLSchema schema) {
  final queryType = schema.queryType;
  if (queryType != null && queryType.name != 'Query') {
    return false;
  }

  final mutationType = schema.mutationType;
  if (mutationType != null && mutationType.name != 'Mutation') {
    return false;
  }

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

  return true;
}