feat(query): add name to interface (#716)

This commit is contained in:
u9g 2023-08-11 01:22:12 -04:00 committed by GitHub
parent a953a96529
commit c7fc1d99b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View file

@ -106,6 +106,11 @@ impl<'a, 'b: 'a> trustfall::provider::Adapter<'a> for &'a Adapter<'b> {
property_name.as_ref(),
resolve_info,
),
"InterfaceAST" | "Interface" => super::properties::resolve_interface_property(
contexts,
property_name.as_ref(),
resolve_info,
),
"InterfaceExtend" => super::properties::resolve_interface_extend_property(
contexts,
property_name.as_ref(),

View file

@ -228,6 +228,23 @@ pub(super) fn resolve_import_property<'a, 'b: 'a>(
}
}
pub(super) fn resolve_interface_property<'a, 'b: 'a>(
contexts: ContextIterator<'a, Vertex<'b>>,
property_name: &str,
_resolve_info: &ResolveInfo,
) -> ContextOutcomeIterator<'a, Vertex<'b>, FieldValue> {
match property_name {
"name" => resolve_property_with(contexts, |v| {
v.as_interface().unwrap().interface.id.name.to_string().into()
}),
_ => {
unreachable!(
"attempted to read unexpected property '{property_name}' on type 'InterfaceExtend'"
)
}
}
}
pub(super) fn resolve_interface_extend_property<'a, 'b: 'a>(
contexts: ContextIterator<'a, Vertex<'b>>,
property_name: &str,

View file

@ -201,6 +201,7 @@ interface InterfaceExtend {
}
interface Interface {
name: String!
extend: [InterfaceExtend!]!
name_span: Span!
entire_span: Span!
@ -355,6 +356,7 @@ type TypeAnnotationAST implements TypeAnnotation & ASTNode & HasSpan {
}
type InterfaceAST implements Interface & ASTNode & HasSpan {
name: String!
extend: [InterfaceExtend!]!
name_span: Span!
entire_span: Span!