code: def leave_Directive(self, node, *args):
          
          name_to_arg_value = {
              # Taking [0] is ok here because the GraphQL parser checks for the
              # existence of ':' in directive arguments.
              arg.split(':', 1)[0]: arg
              for arg in node.arguments
          }
  
          ordered_args = node.arguments
          directive = DIRECTIVES_BY_NAME.get(node.name)
          if directive:
              sorted_args = []
              encountered_argument_names = set()
  
              # Iterate through all defined arguments in the directive schema.
              for defined_arg_name in six.iterkeys(directive.args):
                  if defined_arg_name in name_to_arg_value:
                      # The argument was present in the query, print it in the correct order.
                      encountered_argument_names.add(defined_arg_name)
                      sorted_args.append(name_to_arg_value[defined_arg_name])
  
              # Get all the arguments that weren't defined in the directive schema.
              # They will be printed after all the arguments that were in the schema.
              unsorted_args = [
                  value
                  for name, value in six.iteritems(name_to_arg_value)
                  if name not in encountered_argument_names
              ]
  
              ordered_args = sorted_args + unsorted_args
  
          return '@' + node.name + wrap('(', join(ordered_args, ', '), ')')
docs: Call when exiting a directive node in the ast.