from graphene.types import Scalar
from graphql.language import ast


class AttributesFilterScalar(Scalar):

    @staticmethod
    def coerce_filter(value):
        if isinstance(value, tuple) and len(value) == 2:
            return ":".join(value)

    serialize = coerce_filter
    parse_value = coerce_filter

    @staticmethod
    def parse_literal(node):
        if isinstance(node, ast.StringValue):
            splitted = node.value.split(":")
            if len(splitted) == 2:
                return tuple(splitted)

from graphene.types import Scalar
from graphql.language import ast


class AttributesFilterScalar(Scalar):

    @staticmethod
    def parse_literal(node):
        if isinstance(node, ast.StringValue):
            splitted = node.value.split(":")
            if len(splitted) == 2:
                return tuple(splitted)

    @staticmethod
    def parse_value(value):
        if isinstance(value, basestring):
            splitted = value.split(":")
            if len(splitted) == 2:
                return tuple(splitted)

    @staticmethod
    def serialize(value):
        if isinstance(value, tuple) and len(value) == 2:
            return ":".join(value)

Fix parsing attributes filter values in GraphQL API
Fix parsing attributes filter values in GraphQL API

  from graphene.types import Scalar
  from graphql.language import ast
  
  
  class AttributesFilterScalar(Scalar):
- 
-     @staticmethod
-     def coerce_filter(value):
-         if isinstance(value, tuple) and len(value) == 2:
-             return ":".join(value)
- 
-     serialize = coerce_filter
-     parse_value = coerce_filter
  
      @staticmethod
      def parse_literal(node):
          if isinstance(node, ast.StringValue):
              splitted = node.value.split(":")
              if len(splitted) == 2:
                  return tuple(splitted)
  
+     @staticmethod
+     def parse_value(value):
+         if isinstance(value, basestring):
+             splitted = value.split(":")
+             if len(splitted) == 2:
+                 return tuple(splitted)
+ 
+     @staticmethod
+     def serialize(value):
+         if isinstance(value, tuple) and len(value) == 2:
+             return ":".join(value)
+ 
Fix parsing attributes filter values in GraphQL API
## Code Before:
from graphene.types import Scalar
from graphql.language import ast


class AttributesFilterScalar(Scalar):

    @staticmethod
    def coerce_filter(value):
        if isinstance(value, tuple) and len(value) == 2:
            return ":".join(value)

    serialize = coerce_filter
    parse_value = coerce_filter

    @staticmethod
    def parse_literal(node):
        if isinstance(node, ast.StringValue):
            splitted = node.value.split(":")
            if len(splitted) == 2:
                return tuple(splitted)

## Instruction:
Fix parsing attributes filter values in GraphQL API
## Code After:
from graphene.types import Scalar
from graphql.language import ast


class AttributesFilterScalar(Scalar):

    @staticmethod
    def parse_literal(node):
        if isinstance(node, ast.StringValue):
            splitted = node.value.split(":")
            if len(splitted) == 2:
                return tuple(splitted)

    @staticmethod
    def parse_value(value):
        if isinstance(value, basestring):
            splitted = value.split(":")
            if len(splitted) == 2:
                return tuple(splitted)

    @staticmethod
    def serialize(value):
        if isinstance(value, tuple) and len(value) == 2:
            return ":".join(value)
