Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Change FulfillmentLines in API to a list

fowczarek97f7c6b454e2
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index 513323cf17..0937787d27 100644
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -74,10 +74,24 @@ class OrderEvent(CountableDjangoObjectType):
return self.order_id
+class FulfillmentLine(CountableDjangoObjectType):
+ order_line = graphene.Field(lambda: OrderLine)
+
+ class Meta:
+ description = 'Represents line of the fulfillment.'
+ interfaces = [relay.Node]
+ model = models.FulfillmentLine
+ exclude_fields = ['fulfillment']
+
+ @gql_optimizer.resolver_hints(prefetch_related='order_line')
+ def resolve_order_line(self, info):
+ return self.order_line
+
+
class Fulfillment(CountableDjangoObjectType):
- lines = gql_optimizer.field(
- PrefetchingConnectionField(lambda: FulfillmentLine),
- model_field='lines')
+ lines = graphene.List(
+ FulfillmentLine,
+ description='List of fulfillment lines for the fulfillment')
status_display = graphene.String(
description='User-friendly fulfillment status.')
@@ -94,20 +108,6 @@ class Fulfillment(CountableDjangoObjectType):
return self.get_status_display()
-class FulfillmentLine(CountableDjangoObjectType):
- order_line = graphene.Field(lambda: OrderLine)
-
- class Meta:
- description = 'Represents line of the fulfillment.'
- interfaces = [relay.Node]
- model = models.FulfillmentLine
- exclude_fields = ['fulfillment']
-
- @gql_optimizer.resolver_hints(prefetch_related='order_line')
- def resolve_order_line(self, info):
- return self.order_line
-
-
class OrderLine(CountableDjangoObjectType):
thumbnail_url = graphene.String(
description='The URL of a main thumbnail for the ordered product.',
diff --git a/tests/api/test_fulfillment.py b/tests/api/test_fulfillment.py
index 59918bc9f1..0686a7d969 100644
--- a/tests/api/test_fulfillment.py
+++ b/tests/api/test_fulfillment.py
@@ -25,7 +25,7 @@ CREATE_FULFILLMENT_QUERY = """
status
trackingNumber
lines {
- totalCount
+ id
}
}
}
@@ -54,7 +54,7 @@ def test_create_fulfillment(
assert data['fulfillmentOrder'] == 1
assert data['status'] == FulfillmentStatus.FULFILLED.upper()
assert data['trackingNumber'] == tracking
- assert data['lines']['totalCount'] == 1
+ assert len(data['lines']) == 1
event_fulfillment, event_email_sent = order.events.all()
assert event_fulfillment.type == (