code: def scalar_leaf_only(operator):
      
      def decorator(f):
          """Decorate the supplied function with the "scalar_leaf_only" logic."""
          @wraps(f)
          def wrapper(filter_operation_info, context, parameters, *args, **kwargs):
              """Check that the type on which the operator operates is a scalar leaf type."""
              if 'operator' in kwargs:
                  current_operator = kwargs['operator']
              else:
                  # Because "operator" is from an enclosing scope, it is immutable in Python 2.x.
                  current_operator = operator
  
              if not is_leaf_type(filter_operation_info.field_type):
                  raise GraphQLCompilationError(u'Cannot apply "{}" filter to non-leaf type'
                                                u'{}'.format(current_operator, filter_operation_info))
              return f(filter_operation_info, context, parameters, *args, **kwargs)
  
          return wrapper
  
      return decorator
docs: Ensure the filter function is only applied to scalar leaf types.