feat(graphene): add address line fields to CreateAddress mutation
include `address_line_1` and optional `address_line_2` to enhance address creation functionality.
This commit is contained in:
parent
c889c20b61
commit
6c1dbe0c5f
1 changed files with 9 additions and 2 deletions
|
|
@ -619,14 +619,21 @@ class CreateAddress(Mutation):
|
||||||
raw_data = String(
|
raw_data = String(
|
||||||
required=True, description=_("original address string provided by the user")
|
required=True, description=_("original address string provided by the user")
|
||||||
)
|
)
|
||||||
|
address_line_1 = String(required=True)
|
||||||
|
address_line_2 = String(required=False)
|
||||||
|
|
||||||
address = Field(AddressType)
|
address = Field(AddressType)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mutate(parent, info, raw_data):
|
def mutate(parent, info, raw_data, address_line_1, address_line_2=None):
|
||||||
user = info.context.user if info.context.user.is_authenticated else None
|
user = info.context.user if info.context.user.is_authenticated else None
|
||||||
|
|
||||||
address = Address.objects.create(raw_data=raw_data, user=user)
|
address = Address.objects.create(
|
||||||
|
raw_data=raw_data,
|
||||||
|
user=user,
|
||||||
|
address_line_1=address_line_1,
|
||||||
|
address_line_2=address_line_2,
|
||||||
|
)
|
||||||
return CreateAddress(address=address) # ty: ignore[unknown-argument]
|
return CreateAddress(address=address) # ty: ignore[unknown-argument]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue