Skip to content

M2M connection is broken #172

Closed
Closed
@kozickikarol

Description

@kozickikarol

Hi,

I have following models:

class Place(models.Model):
    categories = models.ManyToManyField(PlaceCategory, related_name='places')
class PlaceCategory(models.Model):
    name = models.CharField(max_length=255, unique=True)

Furthermore, I have following DjangoObjectType models:

class PlaceNode(DjangoObjectType):
    class Meta:
        model = Place
        interfaces = (graphene.relay.Node, )
class PlaceCategoryNode(DjangoObjectType):
    class Meta:
        model = PlaceCategory
        interfaces = (graphene.relay.Node, )

Then when I execute this query:

{
  placeCategories {
    edges {
      node {
        id
        places {
          edges {
            node {
              id
            }
          }
        }
      }
    }
  }
}

everything works great but when I try to execute this one:

{
  places {
    edges {
      node {
        id
        categories {
          edges {
            node {
              id
            }
          }
        }
      }
    }
  }
}

I get errors:

Cannot combine queries on two different base models.

It seems that M2M connection is working improperly and it is unable to fetch related objects from instance where M2M is defined.

Has anyone run into the same problem ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions