# Constraints:
# - 'op_name' can only contain characters [A-Za-z_];
# - cannot be used at or within vertex fields marked @fold;
# - strings in 'value' can be encoded as '%tag_name' if referring to a tag named 'tag_name',
#   or as '$parameter_name' if referring to a parameter 'parameter_name' which will be provided
#   to the query at execution time.
FilterDirective = GraphQLDirective(
    name='filter',
    args=OrderedDict([(
        'op_name', GraphQLArgument(
            type=GraphQLNonNull(GraphQLString),
            description='Name of the filter operation to perform.',
        )),
        ('value', GraphQLArgument(
            type=GraphQLNonNull(GraphQLList(GraphQLNonNull(GraphQLString))),
            description='List of string operands for the operator.',
        ))]
    ),
    locations=[
        DirectiveLocation.FIELD,
        DirectiveLocation.INLINE_FRAGMENT,
    ]
)


# Constraints:
# - 'tag_name' can only contain characters [A-Za-z_];
# - 'tag_name' has to be distinct for each @output directive;
# - can only be applied to property fields;
# - cannot be applied to fields within a scope marked @fold.
# Copyright 2019-present Kensho Technologies, LLC.
from collections import OrderedDict
from copy import copy
from itertools import chain

from graphql import (DirectiveLocation, GraphQLArgument, GraphQLDirective,
                     GraphQLNonNull, GraphQLString)

from ...schema import (FilterDirective, FoldDirective, OptionalDirective,
                       RecurseDirective, TagDirective)

MacroEdgeDirective = GraphQLDirective(
    name='macro_edge',
    locations=[
        # Used to mark edges that are defined via macros in the schema.
        DirectiveLocation.FIELD_DEFINITION,
    ],
)

MacroEdgeDefinitionDirective = GraphQLDirective(
    name='macro_edge_definition',
    args=OrderedDict([
        ('name',
         GraphQLArgument(
             type=GraphQLNonNull(GraphQLString),
             description='Name of the filter operation to perform.',
         )),
    ]),
    locations=[
        DirectiveLocation.FIELD,
    ],