diff --git a/server/basicknowledge/queries.py b/server/basicknowledge/queries.py index 8304d3e0..38bf75a8 100644 --- a/server/basicknowledge/queries.py +++ b/server/basicknowledge/queries.py @@ -64,4 +64,4 @@ class InstrumentQuery(object): return BasicKnowledge.objects.all().live() def resolve_instrument_types(self, info, **kwargs): - return InstrumentType.objects.filter(instruments__isnull=False) + return InstrumentType.objects.filter(instruments__isnull=False).distinct() diff --git a/server/basicknowledge/tests/test_instrument_types_query.py b/server/basicknowledge/tests/test_instrument_types_query.py index d90b3f4e..1073b01e 100644 --- a/server/basicknowledge/tests/test_instrument_types_query.py +++ b/server/basicknowledge/tests/test_instrument_types_query.py @@ -20,6 +20,10 @@ class InstrumentTypesQueryTestCase(SkillboxTestCase): InstrumentTypeFactory(name='Guitar') self.instrument = InstrumentFactory(new_type=self.type) InstrumentFactory(new_type=second_type) + InstrumentFactory(new_type=second_type) + InstrumentFactory(new_type=second_type) + InstrumentFactory(new_type=second_type) + InstrumentFactory(new_type=second_type) def test_instrument_types_empty_not_returned(self): result = self.get_client().get_result(INSTRUMENT_TYPES_QUERY)