getDirectivesFromElement function

  1. @experimental
Iterable<DirectiveNode> getDirectivesFromElement(
  1. GraphQLElement element
)

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 [];
  }
}