Skip to content
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

Add schema.root_operation_name(OperationType) HIR helper method #579

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions crates/apollo-compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Maintenance
## Documentation -->

# [x.x.x] (unreleased) - 2023-mm-dd

## Features
- add `root_operation_name(OperationType)` helper method on `hir::SchemaDefinition` by [SimonSapin] in [pull/579]

[pull/579]: https://github.com/apollographql/apollo-rs/pull/579

# [0.9.4](https://crates.io/crates/apollo-compiler/0.9.4) - 2023-06-05

## Features
Expand Down
13 changes: 13 additions & 0 deletions crates/apollo-compiler/src/database/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,19 @@ impl SchemaDefinition {
&self.extensions
}

/// Returns the name of the object type for the root operation of the given kind,
/// defined either on this schema defintion or its extensions.
///
/// The corresponding object type definition can be found
/// at [`compiler.db.object_types().get(name)`][HirDatabase::object_types].
pub fn root_operation_name(&self, ty: OperationType) -> Option<&str> {
match ty {
OperationType::Query => self.query(),
OperationType::Mutation => self.mutation(),
OperationType::Subscription => self.subscription(),
}
}

/// Returns the name of the object type for the `query` root operation,
/// defined either on this schema defintion or its extensions.
///
Expand Down