Skip to content

Expose getOperationRootType(schema, operationNode) #1345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/type/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
GraphQLObjectType,
} from './definition';
import type {
OperationTypeNode,
SchemaDefinitionNode,
SchemaExtensionNode,
} from '../language/ast';
Expand Down Expand Up @@ -172,6 +173,17 @@ export class GraphQLSchema {
});
}

getOperationType(operation: OperationTypeNode): ?GraphQLObjectType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you drop the ? here when you add a default case like this:

default:
  (operation: empty);
  invariant(false, 'Unexpected operation: `%s`', operation);

switch (operation) {
case 'query':
return this.getQueryType();
case 'mutation':
return this.getMutationType();
case 'subscription':
return this.getSubscriptionType();
}
}

getQueryType(): ?GraphQLObjectType {
return this._queryType;
}
Expand Down