getDirectivesFromElement function
Returns the directives applied to a given GraphQL element
Implementation
@experimental
Iterable<DirectiveNode> getDirectivesFromElement(GraphQLElement element) {
final _fromAttachments = getDirectivesFromAttachments(element.attachments);
if (element is GraphQLNamedType) {
return element.extra.directives();
} else if (element is GraphQLObjectField) {
return (element.astNode?.directives ?? []).followedBy(_fromAttachments);
} else if (element is GraphQLFieldInput) {
return (element.astNode?.directives ?? []).followedBy(_fromAttachments);
} else if (element is GraphQLEnumValue) {
return (element.astNode?.directives ?? []).followedBy(_fromAttachments);
} else {
return [];
}
}