Skip to content

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

Merge branch 'master' into skip-count-unless-necessary

Marcin Gębala7c3996bc054f
diff --cc poetry.lock
index d054cf0fcb,dbd32b6e0d..188a9b41b9
--- a/poetry.lock
+++ b/poetry.lock
@@@ -182,10 -148,10 +148,10 @@@ description = "The AWS SDK for Python
name = "boto3"
optional = false
python-versions = "*"
- version = "1.12.16"
-version = "1.12.36"
++version = "1.12.42"
[package.dependencies]
- botocore = ">=1.15.16,<1.16.0"
-botocore = ">=1.15.36,<1.16.0"
++botocore = ">=1.15.42,<1.16.0"
jmespath = ">=0.7.1,<1.0.0"
s3transfer = ">=0.3.0,<0.4.0"
@@@ -195,7 -161,7 +161,7 @@@ description = "Low-level, data-driven c
name = "botocore"
optional = false
python-versions = "*"
- version = "1.15.16"
-version = "1.15.36"
++version = "1.15.42"
[package.dependencies]
docutils = ">=0.10,<0.16"
@@@ -223,7 -189,7 +189,7 @@@ description = "Extensible memoizing col
name = "cachetools"
optional = false
python-versions = "~=3.5"
--version = "4.0.0"
++version = "4.1.0"
[[package]]
category = "main"
@@@ -836,10 -784,10 +784,10 @@@ description = "Google API client core l
name = "google-api-core"
optional = false
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*"
--version = "1.16.0"
++version = "1.17.0"
[package.dependencies]
--google-auth = ">=0.4.0,<2.0dev"
++google-auth = ">=1.14.0,<2.0dev"
googleapis-common-protos = ">=1.6.0,<2.0dev"
protobuf = ">=3.4.0"
pytz = "*"
@@@ -858,7 -806,7 +806,7 @@@ description = "Google Authentication Li
name = "google-auth"
optional = false
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*"
- version = "1.11.2"
-version = "1.13.1"
++version = "1.14.0"
[package.dependencies]
cachetools = ">=2.0.0,<5.0"
@@@ -1133,7 -1073,7 +1073,7 @@@ description = "A very fast and expressi
name = "jinja2"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
--version = "2.11.1"
++version = "2.11.2"
[package.dependencies]
MarkupSafe = ">=0.23"
@@@ -1368,7 -1308,7 +1308,7 @@@ description = "Utility library for giti
name = "pathspec"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
--version = "0.7.0"
++version = "0.8.0"
[[package]]
category = "main"
@@@ -1961,7 -1891,7 +1891,7 @@@ description = "Python bindings for the
name = "stripe"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
- version = "2.43.0"
-version = "2.44.0"
++version = "2.45.0"
[package.dependencies]
[package.dependencies.requests]
@@@ -2131,11 -2061,11 +2061,11 @@@ description = "HTTP library with thread
name = "urllib3"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
--version = "1.25.8"
++version = "1.25.9"
[package.extras]
brotli = ["brotlipy (>=0.6.0)"]
--secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
++secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=0.14)", "ipaddress"]
socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"]
[[package]]
@@@ -2178,7 -2108,7 +2108,7 @@@ description = "Virtual Python Environme
name = "virtualenv"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
- version = "20.0.9"
-version = "20.0.16"
++version = "20.0.18"
[package.dependencies]
appdirs = ">=1.4.3,<2"
@@@ -2188,7 -2118,7 +2118,7 @@@ six = ">=1.9.0,<2
[package.extras]
docs = ["sphinx (>=2.0.0,<3)", "sphinx-argparse (>=0.2.5,<1)", "sphinx-rtd-theme (>=0.4.3,<1)", "towncrier (>=19.9.0rc1)", "proselint (>=0.10.2,<1)"]
--testing = ["pytest (>=4.0.0,<6)", "coverage (>=4.5.1,<6)", "pytest-mock (>=2.0.0,<3)", "pytest-env (>=0.6.2,<1)", "pytest-timeout (>=1.3.4,<2)", "packaging (>=20.0)", "xonsh (>=0.9.13,<1)"]
++testing = ["pytest (>=4.0.0,<6)", "coverage (>=4.5.1,<6)", "pytest-mock (>=2.0.0,<3)", "pytest-env (>=0.6.2,<1)", "pytest-timeout (>=1.3.4,<2)", "packaging (>=20.0)", "xonsh (>=0.9.16,<1)"]
[[package]]
category = "dev"
@@@ -2314,25 -2237,21 +2237,21 @@@ black =
{file = "black-19.10b0-py36-none-any.whl", hash = "sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b"},
{file = "black-19.10b0.tar.gz", hash = "sha256:c2edb73a08e9e0e6f65a0e6af18b059b8b1cdd5bef997d7a0b181df93dc81539"},
]
- bleach = [
- {file = "bleach-2.1.4-py2.py3-none-any.whl", hash = "sha256:24754b9a7d530bf30ce7cbc805bc6cce785660b4a10ff3a43633728438c105ab"},
- {file = "bleach-2.1.4.tar.gz", hash = "sha256:0ee95f6167129859c5dce9b1ca291ebdb5d8cd7e382ca0e237dfd0dad63f63d8"},
- ]
boto3 = [
- {file = "boto3-1.12.16-py2.py3-none-any.whl", hash = "sha256:a01e3a373638850822c863914fa56e25fd1a651a48fb9c6323694a634c76289c"},
- {file = "boto3-1.12.16.tar.gz", hash = "sha256:ba1229df5f1e32dee4c8bb73e774dfb7d54e293f0895d4f825294e2d46e3c7b3"},
- {file = "boto3-1.12.36-py2.py3-none-any.whl", hash = "sha256:57397f9ad3e9afc17e6100a38c6e631b6545aabc7f8c38b86ff2c6f5931d0ebf"},
- {file = "boto3-1.12.36.tar.gz", hash = "sha256:911994ef46595e8ab9f08eee6b666caea050937b96d54394292e958330cd7ad5"},
++ {file = "boto3-1.12.42-py2.py3-none-any.whl", hash = "sha256:c205c9d69beb43f1dee6f8c30029a418afe1f82fc52a254d9f3b5ab24ee5dd00"},
++ {file = "boto3-1.12.42.tar.gz", hash = "sha256:bd005143eadea91dcba536caffcdd19d9a4dbefa7f59ddd503ef0ef2e5079c36"},
]
botocore = [
- {file = "botocore-1.15.16-py2.py3-none-any.whl", hash = "sha256:1109f36e658de2097d1e466842d6634a6b66bb9d3779abe16698171360e1ae5f"},
- {file = "botocore-1.15.16.tar.gz", hash = "sha256:39e903e1d1ae862e469b4d5f15dc6770a7c9c81da9fcffb1a40f551ea36acd35"},
- {file = "botocore-1.15.36-py2.py3-none-any.whl", hash = "sha256:d2233e19b6a60792185b15fe4cd8f92c5579298e5079daf17f66f6e639585e3a"},
- {file = "botocore-1.15.36.tar.gz", hash = "sha256:5fc5e8629b5375d591a47d05baaff6ccdf5c3b617aad1e14286be458092c9e53"},
++ {file = "botocore-1.15.42-py2.py3-none-any.whl", hash = "sha256:1b7730de543a751c2491f1510688f3c34a8b9669998d8b88f8facf6c3be3c790"},
++ {file = "botocore-1.15.42.tar.gz", hash = "sha256:2ce77c2b11253b64a3d7ec0aa696c064d6ed83c32e6288fc2d59f485f8119828"},
]
braintree = [
{file = "braintree-3.49.0-py2.py3-none-any.whl", hash = "sha256:7cdd715a5a61339e4e5dcb5611cf80512d5fdb0e4da69307a64141d3597357f7"},
{file = "braintree-3.49.0.tar.gz", hash = "sha256:0c95dbe0b497fd2eafaa08b6282f2b1d547cba3a432f8101424bd06c333348b5"},
]
cachetools = [
-- {file = "cachetools-4.0.0-py3-none-any.whl", hash = "sha256:b304586d357c43221856be51d73387f93e2a961598a9b6b6670664746f3b6c6c"},
-- {file = "cachetools-4.0.0.tar.gz", hash = "sha256:9a52dd97a85f257f4e4127f15818e71a0c7899f121b34591fcc1173ea79a0198"},
++ {file = "cachetools-4.1.0-py3-none-any.whl", hash = "sha256:de5d88f87781602201cde465d3afe837546663b168e8b39df67411b0bf10cefc"},
++ {file = "cachetools-4.1.0.tar.gz", hash = "sha256:1d057645db16ca7fe1f3bd953558897603d6f0b9c51ed9d11eb4d071ec4e2aab"},
]
cairocffi = [
{file = "cairocffi-1.1.0.tar.gz", hash = "sha256:f1c0c5878f74ac9ccb5d48b2601fcc75390c881ce476e79f4cfedd288b1b05db"},
@@@ -2571,12 -2486,12 +2486,12 @@@ freezegun =
{file = "freezegun-0.3.15.tar.gz", hash = "sha256:e2062f2c7f95cc276a834c22f1a17179467176b624cc6f936e8bc3be5535ad1b"},
]
google-api-core = [
-- {file = "google-api-core-1.16.0.tar.gz", hash = "sha256:92e962a087f1c4b8d1c5c88ade1c1dfd550047dcffb320c57ef6a534a20403e2"},
-- {file = "google_api_core-1.16.0-py2.py3-none-any.whl", hash = "sha256:859f7392676761f2b160c6ee030c3422135ada4458f0948c5690a6a7c8d86294"},
++ {file = "google-api-core-1.17.0.tar.gz", hash = "sha256:e4082a0b479dc2dee2f8d7b80ea8b5d0184885b773caab15ab1836277a01d689"},
++ {file = "google_api_core-1.17.0-py2.py3-none-any.whl", hash = "sha256:c0e430658ed6be902d7ba7095fb0a9cac810270d71bf7ac4484e76c300407aae"},
]
google-auth = [
- {file = "google-auth-1.11.2.tar.gz", hash = "sha256:1ee22e22f35d6e00f068d7b3999b2ce24ecb5d0dcbd485aa6896d2b83c8907d6"},
- {file = "google_auth-1.11.2-py2.py3-none-any.whl", hash = "sha256:28a848d47c55075a0f29d7e26b7a213515c137ab8f0670e546e46d1277060e47"},
- {file = "google-auth-1.13.1.tar.gz", hash = "sha256:a5ee4c40fef77ea756cf2f1c0adcf475ecb53af6700cf9c133354cdc9b267148"},
- {file = "google_auth-1.13.1-py2.py3-none-any.whl", hash = "sha256:cab6c707e6ee20e567e348168a5c69dc6480384f777a9e5159f4299ad177dcc0"},
++ {file = "google-auth-1.14.0.tar.gz", hash = "sha256:9813eaae335c45e8a1b5d274610fa961ac8aa650568d1cfb005b2c07da6bde6c"},
++ {file = "google_auth-1.14.0-py2.py3-none-any.whl", hash = "sha256:050f1713142fa57d4b34f4fd4a998210e330f6a29c84c6ce359b928cc11dc8ad"},
]
google-cloud-core = [
{file = "google-cloud-core-1.3.0.tar.gz", hash = "sha256:878f9ad080a40cdcec85b92242c4b5819eeb8f120ebc5c9f640935e24fc129d8"},
@@@ -2648,8 -2560,8 +2560,8 @@@ jaeger-client =
{file = "jaeger-client-4.3.0.tar.gz", hash = "sha256:7f72c341a21e3dcbc8498d1ed17c93e0eec71c5becc5c9333c4293793d4e6433"},
]
jinja2 = [
-- {file = "Jinja2-2.11.1-py2.py3-none-any.whl", hash = "sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49"},
-- {file = "Jinja2-2.11.1.tar.gz", hash = "sha256:93187ffbc7808079673ef52771baa950426fd664d3aad1d0fa3e95644360e250"},
++ {file = "Jinja2-2.11.2-py2.py3-none-any.whl", hash = "sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035"},
++ {file = "Jinja2-2.11.2.tar.gz", hash = "sha256:89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0"},
]
jmespath = [
{file = "jmespath-0.9.5-py2.py3-none-any.whl", hash = "sha256:695cb76fa78a10663425d5b73ddc5714eb711157e52704d69be03b1a02ba4fec"},
@@@ -2828,36 -2740,37 +2740,37 @@@ packaging =
{file = "packaging-20.3.tar.gz", hash = "sha256:3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3"},
]
pathspec = [
-- {file = "pathspec-0.7.0-py2.py3-none-any.whl", hash = "sha256:163b0632d4e31cef212976cf57b43d9fd6b0bac6e67c26015d611a647d5e7424"},
-- {file = "pathspec-0.7.0.tar.gz", hash = "sha256:562aa70af2e0d434367d9790ad37aed893de47f1693e4201fd1d3dca15d19b96"},
++ {file = "pathspec-0.8.0-py2.py3-none-any.whl", hash = "sha256:7d91249d21749788d07a2d0f94147accd8f845507400749ea19c1ec9054a12b0"},
++ {file = "pathspec-0.8.0.tar.gz", hash = "sha256:da45173eb3a6f2a5a487efba21f050af2b41948be6ab52b6a1e3ff22bb8b7061"},
]
phonenumberslite = [
- {file = "phonenumberslite-8.11.5-py2.py3-none-any.whl", hash = "sha256:0982ee5c15b0d89f1ab23cd0d303eddbac7a424c809fa44f5dbec9718db9821a"},
- {file = "phonenumberslite-8.11.5.tar.gz", hash = "sha256:5ea41aedc3bb4a7723bc23cf3faf64c69dd2935315ff8319b38dbd13e6b01466"},
+ {file = "phonenumberslite-8.12.1-py2.py3-none-any.whl", hash = "sha256:f0c2c992e894bc3f46647b71489ef8d88d0248796b877b732d882e80ac2fd10f"},
+ {file = "phonenumberslite-8.12.1.tar.gz", hash = "sha256:54231daa23593fd1b3b2e32200119316a2ad3f3eddd873bfe62c8247e582d600"},
]
pillow = [
- {file = "Pillow-7.0.0-cp35-cp35m-macosx_10_6_intel.whl", hash = "sha256:5f3546ceb08089cedb9e8ff7e3f6a7042bb5b37c2a95d392fb027c3e53a2da00"},
- {file = "Pillow-7.0.0-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:9d2ba4ed13af381233e2d810ff3bab84ef9f18430a9b336ab69eaf3cd24299ff"},
- {file = "Pillow-7.0.0-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:ff3797f2f16bf9d17d53257612da84dd0758db33935777149b3334c01ff68865"},
- {file = "Pillow-7.0.0-cp35-cp35m-win32.whl", hash = "sha256:c18f70dc27cc5d236f10e7834236aff60aadc71346a5bc1f4f83a4b3abee6386"},
- {file = "Pillow-7.0.0-cp35-cp35m-win_amd64.whl", hash = "sha256:875358310ed7abd5320f21dd97351d62de4929b0426cdb1eaa904b64ac36b435"},
- {file = "Pillow-7.0.0-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:ab76e5580b0ed647a8d8d2d2daee170e8e9f8aad225ede314f684e297e3643c2"},
- {file = "Pillow-7.0.0-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:a62ec5e13e227399be73303ff301f2865bf68657d15ea50b038d25fc41097317"},
- {file = "Pillow-7.0.0-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:8ac6ce7ff3892e5deaab7abaec763538ffd011f74dc1801d93d3c5fc541feee2"},
- {file = "Pillow-7.0.0-cp36-cp36m-win32.whl", hash = "sha256:91b710e3353aea6fc758cdb7136d9bbdcb26b53cefe43e2cba953ac3ee1d3313"},
- {file = "Pillow-7.0.0-cp36-cp36m-win_amd64.whl", hash = "sha256:bf598d2e37cf8edb1a2f26ed3fb255191f5232badea4003c16301cb94ac5bdd0"},
- {file = "Pillow-7.0.0-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:5bfef0b1cdde9f33881c913af14e43db69815c7e8df429ceda4c70a5e529210f"},
- {file = "Pillow-7.0.0-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:dc058b7833184970d1248135b8b0ab702e6daa833be14035179f2acb78ff5636"},
- {file = "Pillow-7.0.0-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c5ed816632204a2fc9486d784d8e0d0ae754347aba99c811458d69fcdfd2a2f9"},
- {file = "Pillow-7.0.0-cp37-cp37m-win32.whl", hash = "sha256:54ebae163e8412aff0b9df1e88adab65788f5f5b58e625dc5c7f51eaf14a6837"},
- {file = "Pillow-7.0.0-cp37-cp37m-win_amd64.whl", hash = "sha256:87269cc6ce1e3dee11f23fa515e4249ae678dbbe2704598a51cee76c52e19cda"},
- {file = "Pillow-7.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0a628977ac2e01ca96aaae247ec2bd38e729631ddf2221b4b715446fd45505be"},
- {file = "Pillow-7.0.0-cp38-cp38-manylinux1_i686.whl", hash = "sha256:62a889aeb0a79e50ecf5af272e9e3c164148f4bd9636cc6bcfa182a52c8b0533"},
- {file = "Pillow-7.0.0-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:bf4003aa538af3f4205c5fac56eacaa67a6dd81e454ffd9e9f055fff9f1bc614"},
- {file = "Pillow-7.0.0-cp38-cp38-win32.whl", hash = "sha256:7406f5a9b2fd966e79e6abdaf700585a4522e98d6559ce37fc52e5c955fade0a"},
- {file = "Pillow-7.0.0-cp38-cp38-win_amd64.whl", hash = "sha256:5f7ae9126d16194f114435ebb79cc536b5682002a4fa57fa7bb2cbcde65f2f4d"},
- {file = "Pillow-7.0.0-pp373-pypy36_pp73-win32.whl", hash = "sha256:8453f914f4e5a3d828281a6628cf517832abfa13ff50679a4848926dac7c0358"},
- {file = "Pillow-7.0.0.tar.gz", hash = "sha256:4d9ed9a64095e031435af120d3c910148067087541131e82b3e8db302f4c8946"},
+ {file = "Pillow-7.1.1-cp35-cp35m-macosx_10_10_intel.whl", hash = "sha256:b7453750cf911785009423789d2e4e5393aae9cbb8b3f471dab854b85a26cb89"},
+ {file = "Pillow-7.1.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:4510c6b33277970b1af83c987277f9a08ec2b02cc20ac0f9234e4026136bb137"},
+ {file = "Pillow-7.1.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:b99b2607b6cd58396f363b448cbe71d3c35e28f03e442ab00806463439629c2c"},
+ {file = "Pillow-7.1.1-cp35-cp35m-win32.whl", hash = "sha256:cd47793f7bc9285a88c2b5551d3f16a2ddd005789614a34c5f4a598c2a162383"},
+ {file = "Pillow-7.1.1-cp35-cp35m-win_amd64.whl", hash = "sha256:04a10558320eba9137d6a78ca6fc8f4a5801f1b971152938851dc4629d903579"},
+ {file = "Pillow-7.1.1-cp36-cp36m-macosx_10_10_x86_64.whl", hash = "sha256:50a10b048f4dd81c092adad99fa5f7ba941edaf2f9590510109ac2a15e706695"},
+ {file = "Pillow-7.1.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:721c04d3c77c38086f1f95d1cd8df87f2f9a505a780acf8575912b3206479da1"},
+ {file = "Pillow-7.1.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:a5dc9f28c0239ec2742d4273bd85b2aa84655be2564db7ad1eb8f64b1efcdc4c"},
+ {file = "Pillow-7.1.1-cp36-cp36m-win32.whl", hash = "sha256:d6bf085f6f9ec6a1724c187083b37b58a8048f86036d42d21802ed5d1fae4853"},
+ {file = "Pillow-7.1.1-cp36-cp36m-win_amd64.whl", hash = "sha256:251e5618125ec12ac800265d7048f5857a8f8f1979db9ea3e11382e159d17f68"},
+ {file = "Pillow-7.1.1-cp37-cp37m-macosx_10_10_x86_64.whl", hash = "sha256:433bbc2469a2351bea53666d97bb1eb30f0d56461735be02ea6b27654569f80f"},
+ {file = "Pillow-7.1.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:eb84e7e5b07ff3725ab05977ac56d5eeb0c510795aeb48e8b691491be3c5745b"},
+ {file = "Pillow-7.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:3713386d1e9e79cea1c5e6aaac042841d7eef838cc577a3ca153c8bedf570287"},
+ {file = "Pillow-7.1.1-cp37-cp37m-win32.whl", hash = "sha256:291bad7097b06d648222b769bbfcd61e40d0abdfe10df686d20ede36eb8162b6"},
+ {file = "Pillow-7.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:6c1924ed7dbc6ad0636907693bbbdd3fdae1d73072963e71f5644b864bb10b4d"},
+ {file = "Pillow-7.1.1-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:670e58d3643971f4afd79191abd21623761c2ebe61db1c2cb4797d817c4ba1a7"},
+ {file = "Pillow-7.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:8d5799243050c2833c2662b824dfb16aa98e408d2092805edea4300a408490e7"},
+ {file = "Pillow-7.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:da737ab273f4d60ae552f82ad83f7cbd0e173ca30ca20b160f708c92742ee212"},
+ {file = "Pillow-7.1.1-cp38-cp38-win32.whl", hash = "sha256:b2f3e8cc52ecd259b94ca880fea0d15f4ebc6da2cd3db515389bb878d800270f"},
+ {file = "Pillow-7.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:2f0b52a08d175f10c8ea36685115681a484c55d24d0933f9fd911e4111c04144"},
+ {file = "Pillow-7.1.1-pp373-pypy36_pp73-win32.whl", hash = "sha256:90cd441a1638ae176eab4d8b6b94ab4ec24b212ed4c3fbee2a6e74672481d4f8"},
+ {file = "Pillow-7.1.1-py3.8-macosx-10.9-x86_64.egg", hash = "sha256:5eef904c82b5f8e4256e8d420c971357da2884c0b812ba4efa15a7ad2ec66247"},
+ {file = "Pillow-7.1.1.tar.gz", hash = "sha256:0f89ddc77cf421b8cd34ae852309501458942bf370831b4a9b406156b599a14e"},
]
pluggy = [
{file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"},
@@@ -3149,8 -3056,8 +3056,8 @@@ sqlparse =
{file = "sqlparse-0.3.1.tar.gz", hash = "sha256:e162203737712307dfe78860cc56c8da8a852ab2ee33750e33aeadf38d12c548"},
]
stripe = [
- {file = "stripe-2.43.0-py2.py3-none-any.whl", hash = "sha256:023530b91c2fe9a1bbc0ac46d889e0fe0b7cc08f9cf9ab5c87154cdbfe0c6c54"},
- {file = "stripe-2.43.0.tar.gz", hash = "sha256:d7324eae88f40d1a415022b5ba07b521f54a8ee5e07322101fb78b7715db334a"},
- {file = "stripe-2.44.0-py2.py3-none-any.whl", hash = "sha256:c16f92ae001e415340fffd73c97ec29b2e1f6591b905e8741c4ff02eab35e104"},
- {file = "stripe-2.44.0.tar.gz", hash = "sha256:b15ce50cac5961ce63873906eac1492a12ed01a6ba3606aca831a1741b724a29"},
++ {file = "stripe-2.45.0-py2.py3-none-any.whl", hash = "sha256:2592aa78aa8fbd2c7b892edd9eb0b5dd987df60000e156b1fe395c44ac46f1c0"},
++ {file = "stripe-2.45.0.tar.gz", hash = "sha256:8382f1429487ba641e9d8348db32c1d7b235b7de9129f235a668eef2131147fa"},
]
sympy = [
{file = "sympy-1.5.1-py2.py3-none-any.whl", hash = "sha256:4880d3a351558063bd89febda302f220dc4b88de393bba81fa6539a3966f03fa"},
@@@ -3236,8 -3143,8 +3143,8 @@@ unidecode =
{file = "Unidecode-1.1.1.tar.gz", hash = "sha256:2b6aab710c2a1647e928e36d69c21e76b453cd455f4e2621000e54b2a9b8cce8"},
]
urllib3 = [
-- {file = "urllib3-1.25.8-py2.py3-none-any.whl", hash = "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc"},
-- {file = "urllib3-1.25.8.tar.gz", hash = "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"},
++ {file = "urllib3-1.25.9-py2.py3-none-any.whl", hash = "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"},
++ {file = "urllib3-1.25.9.tar.gz", hash = "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527"},
]
uwsgi = [
{file = "uwsgi-2.0.18.tar.gz", hash = "sha256:4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583"},
@@@ -3251,12 -3158,12 +3158,12 @@@ vine =
{file = "vine-1.3.0.tar.gz", hash = "sha256:133ee6d7a9016f177ddeaf191c1f58421a1dcc6ee9a42c58b34bed40e1d2cd87"},
]
virtualenv = [
- {file = "virtualenv-20.0.9-py2.py3-none-any.whl", hash = "sha256:99f131be2f90ff2a8fd711261a27845b6c50fc008bef815e710c7fa844eb1467"},
- {file = "virtualenv-20.0.9.tar.gz", hash = "sha256:5eba85dfa176fde0425b9b3042ed83f05a1b6309a616b8a3e2a9a94f4bfa27b7"},
- {file = "virtualenv-20.0.16-py2.py3-none-any.whl", hash = "sha256:94f647e12d1e6ced2541b93215e51752aecbd1bbb18eb1816e2867f7532b1fe1"},
- {file = "virtualenv-20.0.16.tar.gz", hash = "sha256:6ea131d41c477f6c4b7863948a9a54f7fa196854dbef73efbdff32b509f4d8bf"},
++ {file = "virtualenv-20.0.18-py2.py3-none-any.whl", hash = "sha256:5021396e8f03d0d002a770da90e31e61159684db2859d0ba4850fbea752aa675"},
++ {file = "virtualenv-20.0.18.tar.gz", hash = "sha256:ac53ade75ca189bc97b6c1d9ec0f1a50efe33cbf178ae09452dcd9fd309013c1"},
]
wcwidth = [
- {file = "wcwidth-0.1.8-py2.py3-none-any.whl", hash = "sha256:8fd29383f539be45b20bd4df0dc29c20ba48654a41e661925e612311e9f3c603"},
- {file = "wcwidth-0.1.8.tar.gz", hash = "sha256:f28b3e8a6483e5d49e7f8949ac1a78314e740333ae305b4ba5defd3e74fb37a8"},
+ {file = "wcwidth-0.1.9-py2.py3-none-any.whl", hash = "sha256:cafe2186b3c009a04067022ce1dcd79cb38d8d65ee4f4791b8888d6599d1bbe1"},
+ {file = "wcwidth-0.1.9.tar.gz", hash = "sha256:ee73862862a156bf77ff92b09034fc4825dd3af9cf81bc5b360668d425f3c5f1"},
]
weasyprint = [
{file = "WeasyPrint-51-py3-none-any.whl", hash = "sha256:469974f6e74b1eef71dc56a9b80cc17621f319234d2a4ab656ddd0fd9e66c27f"},
diff --cc requirements.txt
index 793f15c611,e35150bec9..bfccb0430d
--- a/requirements.txt
+++ b/requirements.txt
@@@ -1,28 -1,26 +1,26 @@@
amqp==2.5.2
aniso8601==7.0.0
- asgiref==3.2.3
- autopep8==1.5
+ asgiref==3.2.7
babel==2.7.0
beautifulsoup4==4.7.1
- billiard==3.6.2.0
- bleach==2.1.4
- boto3==1.12.5
- botocore==1.15.5
+ billiard==3.6.3.0
-boto3==1.12.36
-botocore==1.15.36
++boto3==1.12.42
++botocore==1.15.42
braintree==3.49.0
--cachetools==4.0.0
++cachetools==4.1.0
cairocffi==1.1.0
cairosvg==2.4.2
- celery==4.4.0
- certifi==2019.11.28
+ celery==4.4.2
+ certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
- cssselect2==0.2.2
+ cssselect2==0.3.0
defusedxml==0.6.0
dj-database-url==0.5.0
--dj-email-url==0.2.0
- django==3.0.4
- django-appconf==1.0.3
- django-countries==5.5
++dj-email-url==1.0.0
+ django==3.0.5
+ django-appconf==1.0.4
-django-countries==5.5
++django-countries==6.1.2
django-filter==2.2.0
django-graphql-jwt==0.3.0
django-js-asset==1.2.2
@@@ -40,21 -37,20 +37,20 @@@ django-versatileimagefield==2.
docutils==0.15.2
draftjs-sanitizer==1.0.0
enmerkar==0.7.1
--faker==2.0.5
++faker==4.0.3
freezegun==0.3.15
--google-api-core==1.16.0
- google-auth==1.11.2
-google-auth==1.13.1
++google-api-core==1.17.0
++google-auth==1.14.0
google-cloud-core==1.3.0
- google-cloud-storage==1.26.0
+ google-cloud-storage==1.27.0
google-i18n-address==2.3.5
google-measurement-protocol==1.0.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
- gprof2dot==2016.10.13
graphene==2.1.8
- graphene-django==2.8.2
- graphene-django-optimizer==0.6.1
- graphene-federation==0.0.3
-graphene-django==2.9.0
++graphene-django==2.9.1
+ graphene-django-optimizer==0.6.2
-graphene-federation==0.0.3
++graphene-federation==0.1.0
graphql-core==2.3.1
graphql-relay==2.0.1
html-to-draftjs==1.0.1
@@@ -79,7 -73,7 +73,7 @@@ pillow==7.1.
prices==1.0.0
promise==2.3
protobuf==3.11.3
--psycopg2-binary==2.8.4
++psycopg2-binary==2.8.5
purl==1.5
pyasn1==0.4.8
pyasn1-modules==0.2.8
@@@ -102,17 -94,17 +94,17 @@@ sentry-sdk==0.14.
singledispatch==3.4.0.3
six==1.14.0
soupsieve==2.0
- sqlparse==0.3.0
- stripe==2.42.0
+ sqlparse==0.3.1
-stripe==2.44.0
++stripe==2.45.0
sympy==1.5.1
text-unidecode==1.3
threadloop==1.0.2
thrift==0.13.0
tinycss2==1.0.2
- tornado==6.0.3
- tqdm==4.43.0
+ tornado==6.0.4
+ tqdm==4.45.0
typing==3.7.4.1
--urllib3==1.25.8
++urllib3==1.25.9
uwsgi==2.0.18; sys_platform != "win32"
vine==1.3.0
weasyprint==51
diff --cc requirements_dev.txt
index 3e86423fd3,8307d9c15e..c7a35ff968
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@@ -10,36 -9,34 +9,34 @@@ attrs==19.3.
babel==2.7.0
beautifulsoup4==4.7.1
beautifultable==0.7.0
- billiard==3.6.2.0
+ billiard==3.6.3.0
black==19.10b0
- bleach==2.1.4
- boto3==1.12.5
- botocore==1.15.5
-boto3==1.12.36
-botocore==1.15.36
++boto3==1.12.42
++botocore==1.15.42
braintree==3.49.0
--cachetools==4.0.0
++cachetools==4.1.0
cairocffi==1.1.0
cairosvg==2.4.2
- celery==4.4.0
- certifi==2019.11.28
+ celery==4.4.2
+ certifi==2020.4.5.1
cffi==1.14.0
- cfgv==3.0.0
+ cfgv==3.1.0
chardet==3.0.4
- click==7.0
- codecov==2.0.15
+ click==7.1.1
+ codecov==2.0.22
colorama==0.4.3
--coverage==4.5.4
- cssselect2==0.2.2
++coverage==5.1
+ cssselect2==0.3.0
defusedxml==0.6.0
distlib==0.3.0
dj-database-url==0.5.0
--dj-email-url==0.2.0
- django==3.0.4
- django-appconf==1.0.3
- django-countries==5.5
++dj-email-url==1.0.0
+ django==3.0.5
+ django-appconf==1.0.4
-django-countries==5.5
++django-countries==6.1.2
django-debug-toolbar==2.2
django-debug-toolbar-request-history==0.1.1
- django-extensions==2.2.8
+ django-extensions==2.2.9
django-filter==2.2.0
django-graphiql-debug-toolbar==0.1.4
django-graphql-jwt==0.3.0
@@@ -61,23 -57,22 +57,22 @@@ draftjs-sanitizer==1.0.
enmerkar==0.7.1
entrypoints==0.3
execnet==1.7.1
--faker==2.0.5
++faker==4.0.3
filelock==3.0.12
flake8==3.7.9
freezegun==0.3.15
--google-api-core==1.16.0
- google-auth==1.11.2
-google-auth==1.13.1
++google-api-core==1.17.0
++google-auth==1.14.0
google-cloud-core==1.3.0
- google-cloud-storage==1.26.0
+ google-cloud-storage==1.27.0
google-i18n-address==2.3.5
google-measurement-protocol==1.0.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
- gprof2dot==2016.10.13
graphene==2.1.8
- graphene-django==2.8.2
- graphene-django-optimizer==0.6.1
- graphene-federation==0.0.3
-graphene-django==2.9.0
++graphene-django==2.9.1
+ graphene-django-optimizer==0.6.2
-graphene-federation==0.0.3
++graphene-federation==0.1.0
graphql-core==2.3.1
graphql-relay==2.0.1
html-to-draftjs==1.0.1
@@@ -86,10 -81,10 +81,10 @@@ identify==1.4.1
idna==2.9
isort==4.3.21
jaeger-client==4.3.0
--jinja2==2.11.1
- jmespath==0.9.4
++jinja2==2.11.2
+ jmespath==0.9.5
jsonfield==3.1.0
- kombu==4.6.7
+ kombu==4.6.8
lazy-object-proxy==1.4.3
lxml==4.5.0
markdown==3.2.1
@@@ -106,16 -101,16 +101,16 @@@ mypy-extensions==0.4.
nodeenv==1.3.5
oauthlib==3.1.0
opentracing==2.3.0
- packaging==20.1
- pathspec==0.7.0
- phonenumberslite==8.11.4
- pillow==7.0.0
+ packaging==20.3
-pathspec==0.7.0
++pathspec==0.8.0
+ phonenumberslite==8.12.1
+ pillow==7.1.1
pluggy==0.13.1
- pre-commit==1.21.0
+ pre-commit==2.2.0
prices==1.0.0
promise==2.3
protobuf==3.11.3
--psycopg2-binary==2.8.4
++psycopg2-binary==2.8.5
purl==1.5
py==1.8.1
pyasn1==0.4.8
@@@ -127,14 -122,13 +122,13 @@@ pyflakes==2.1.
pyjwt==1.7.1
pylint==2.4.4
pylint-celery==0.3
- pylint-django==2.0.13
-pylint-django==2.0.14
++pylint-django==2.0.15
pylint-plugin-utils==0.6
- pyparsing==2.4.6
+ pyparsing==2.4.7
pyphen==0.9.5
- pytest==5.3.5
+ pytest==5.4.1
pytest-cov==2.8.1
- pytest-django==3.8.0
+ pytest-django==3.9.0
pytest-django-queries==1.1.0
pytest-forked==1.1.3
pytest-mock==1.13.0
@@@ -158,28 -152,28 +152,28 @@@ singledispatch==3.4.0.
six==1.14.0
snowballstemmer==2.0.0
soupsieve==2.0
- sqlparse==0.3.0
- stripe==2.42.0
+ sqlparse==0.3.1
-stripe==2.44.0
++stripe==2.45.0
sympy==1.5.1
text-unidecode==1.3
threadloop==1.0.2
thrift==0.13.0
tinycss2==1.0.2
toml==0.10.0
- tornado==6.0.3
- tox==3.14.5
- tqdm==4.43.0
- transifex-client==0.13.7
+ tornado==6.0.4
+ tox==3.14.6
+ tqdm==4.45.0
-transifex-client==0.13.8
++transifex-client==0.13.9
typed-ast==1.4.1
typing==3.7.4.1
- typing-extensions==3.7.4.1
+ typing-extensions==3.7.4.2
unidecode==1.1.1
--urllib3==1.25.8
++urllib3==1.25.9
uwsgi==2.0.18; sys_platform != "win32"
vcrpy==4.0.2
vine==1.3.0
- virtualenv==20.0.5
- wcwidth==0.1.8
-virtualenv==20.0.16
++virtualenv==20.0.18
+ wcwidth==0.1.9
weasyprint==51
webencodings==0.5.1
wrapt==1.11.2
diff --cc saleor/account/migrations/0041_merge_20200421_0529.py
index 0000000000,0000000000..ced59413ba
new file mode 100644
--- /dev/null
+++ b/saleor/account/migrations/0041_merge_20200421_0529.py
@@@ -1,0 -1,0 +1,13 @@@
++# Generated by Django 3.0.5 on 2020-04-21 10:29
++
++from django.db import migrations
++
++
++class Migration(migrations.Migration):
++
++ dependencies = [
++ ("account", "0040_auto_20200225_0237"),
++ ("account", "0040_auto_20200415_0443"),
++ ]
++
++ operations = []
diff --cc saleor/graphql/core/connection.py
index bb5685adb8,d20fce7e79..5b4710467f
--- a/saleor/graphql/core/connection.py
+++ b/saleor/graphql/core/connection.py
@@@ -3,224 -2,10 +3,223 @@@ from typing import Any, Dict, Iterable
import graphene
import opentracing as ot
-from django.db.models import Manager, QuerySet
-from graphene import Field, List, NonNull, ObjectType, String
+from django.db.models import Manager, Model as DjangoModel, Q, QuerySet
from graphene.relay.connection import Connection
from graphene_django_optimizer.types import OptimizedDjangoObjectType
++from graphql.error import GraphQLError
+from graphql_relay.connection.connectiontypes import Edge, PageInfo
+from graphql_relay.utils import base64, unbase64
+
+from ..core.enums import OrderDirection
+
+ConnectionArguments = Dict[str, Any]
+
+
+def to_global_cursor(values):
+ if not isinstance(values, Iterable):
+ values = [values]
+ values = [value if value is None else str(value) for value in values]
+ return base64(json.dumps(values))
+
+
+def from_global_cursor(cursor) -> List[str]:
+ values = unbase64(cursor)
+ return json.loads(values)
+
+
+def get_field_value(instance: DjangoModel, field_name: str):
+ """Get field value for given field in filter format 'field__foreign_key_field'."""
+ field_path = field_name.split("__")
+ attr = instance
+ for elem in field_path:
+ attr = getattr(attr, elem)
+
+ if callable(attr):
+ return "%s" % attr()
+ return attr
+
+
+def _prepare_filter_expression(
+ field_name: str,
+ index: int,
+ cursor: List[str],
+ sorting_fields: List[str],
+ sorting_direction: str,
+) -> Tuple[Q, Dict[str, Union[str, bool]]]:
+
+ field_expression: Dict[str, Union[str, bool]] = {}
+ extra_expression = Q()
+ for cursor_id, cursor_value in enumerate(cursor[:index]):
+ field_expression[sorting_fields[cursor_id]] = cursor_value
+
+ if sorting_direction == "gt":
+ extra_expression |= Q(**{f"{field_name}__{sorting_direction}": cursor[index]})
+ extra_expression |= Q(**{f"{field_name}__isnull": True})
+ elif cursor[index] is not None:
+ field_expression[f"{field_name}__{sorting_direction}"] = cursor[index]
+ else:
+ field_expression[f"{field_name}__isnull"] = False
+
+ return extra_expression, field_expression
+
+
+def _prepare_filter(
+ cursor: List[str], sorting_fields: List[str], sorting_direction: str
+) -> Q:
+ """Create filter arguments based on sorting fields.
+
+ :param cursor: list of values that are passed from page_info, used for filtering.
+ :param sorting_fields: list of fields that were used for sorting.
+ :param sorting_direction: keyword direction ('lt', gt').
+ :return: Q() in following format
+ (OR: ('first_field__gt', 'first_value_form_cursor'),
+ (AND: ('second_field__gt', 'second_value_form_cursor'),
+ ('first_field', 'first_value_form_cursor')),
+ (AND: ('third_field__gt', 'third_value_form_cursor'),
+ ('second_field', 'second_value_form_cursor'),
+ ('first_field', 'first_value_form_cursor'))
+ )
+ """
+ filter_kwargs = Q()
+ for index, field_name in enumerate(sorting_fields):
+ if cursor[index] is None and sorting_direction == "gt":
+ continue
+
+ extra_expression, field_expression = _prepare_filter_expression(
+ field_name, index, cursor, sorting_fields, sorting_direction
+ )
+ filter_kwargs |= Q(extra_expression, **field_expression)
+
+ return filter_kwargs
+
+
+def _validate_connection_args(args):
+ first = args.get("first")
+ last = args.get("last")
+
+ if first and not (isinstance(first, int) and first > 0):
- raise ValueError('Argument "first" must be a non-negative integer.')
++ raise GraphQLError("Argument `first` must be a non-negative integer.")
+ if last and not (isinstance(last, int) and last > 0):
- raise ValueError('Argument "last" must be a non-negative integer.')
++ raise GraphQLError("Argument `last` must be a non-negative integer.")
+ if first and last:
- raise ValueError('Argument "last" cannot be combined with "first".')
++ raise GraphQLError("Argument `last` cannot be combined with `first`.")
+ if first and args.get("before"):
- raise ValueError('Argument "first" cannot be combined with "before".')
++ raise GraphQLError("Argument `first` cannot be combined with `before`.")
+ if last and args.get("after"):
- raise ValueError('Argument "last" cannot be combined with "after".')
++ raise GraphQLError("Argument `last` cannot be combined with `after`.")
+
+
+def _get_sorting_fields(sort_by, qs):
+ sorting_fields = sort_by.get("field")
+ sorting_attribute = sort_by.get("attribute_id")
+ if sorting_fields and not isinstance(sorting_fields, list):
+ return [sorting_fields]
+ elif not sorting_fields and sorting_attribute is not None:
+ return qs.model.sort_by_attribute_fields()
+ elif not sorting_fields:
+ raise ValueError("Error while preparing cursor values.")
+ return sorting_fields
+
+
+def _get_sorting_direction(sort_by, last=None):
+ direction = sort_by.get("direction", "")
+ sorting_desc = direction == OrderDirection.DESC
+ if last:
+ sorting_desc = not sorting_desc
+ return "lt" if sorting_desc else "gt"
+
+
+def _get_page_info(matching_records, cursor, first, last):
+ requested_count = first or last
+ page_info = {
+ "has_previous_page": False,
+ "has_next_page": False,
+ "start_cursor": None,
+ "end_cursor": None,
+ }
+ records_left = False
+ if requested_count is not None:
+ records_left = len(matching_records) > requested_count
+ has_pages_before = True if cursor else False
+ if first:
+ page_info["has_next_page"] = records_left
+ page_info["has_previous_page"] = has_pages_before
+ elif last:
+ page_info["has_next_page"] = has_pages_before
+ page_info["has_previous_page"] = records_left
+
+ return page_info
+
+
+def _get_edges_for_connection(edge_type, qs, args, sorting_fields):
+ before = args.get("before")
+ after = args.get("after")
+ first = args.get("first")
+ last = args.get("last")
+ cursor = after or before
+ requested_count = first or last
+
+ if last:
+ start_slice, end_slice = 1, None
+ else:
+ start_slice, end_slice = 0, requested_count
+
+ matching_records = list(qs)
+ if last:
+ matching_records = list(reversed(matching_records))
+ if len(matching_records) <= requested_count:
+ start_slice = 0
+ page_info = _get_page_info(matching_records, cursor, first, last)
+ matching_records = matching_records[start_slice:end_slice]
+
+ edges = [
+ edge_type(
+ node=record,
+ cursor=to_global_cursor(
+ [get_field_value(record, field) for field in sorting_fields]
+ ),
+ )
+ for record in matching_records
+ ]
+ if edges:
+ page_info["start_cursor"] = edges[0].cursor
+ page_info["end_cursor"] = edges[-1].cursor
+ return edges, page_info
+
+
+def connection_from_queryset_slice(
+ qs: QuerySet,
+ args: ConnectionArguments = None,
+ connection_type: Any = Connection,
+ edge_type: Any = Edge,
+ page_info_type: Any = PageInfo,
+) -> Connection:
+ """Create a connection object from a QuerySet."""
+ args = args or {}
+ before = args.get("before")
+ after = args.get("after")
+ first = args.get("first")
+ last = args.get("last")
+ _validate_connection_args(args)
+
+ requested_count = first or last
+ end_margin = requested_count + 1 if requested_count else None
+ cursor = after or before
+ cursor = from_global_cursor(cursor) if cursor else None
+
+ sort_by = args.get("sort_by", {})
+ sorting_fields = _get_sorting_fields(sort_by, qs)
+ sorting_direction = _get_sorting_direction(sort_by, last)
+ if cursor and len(cursor) != len(sorting_fields):
- raise ValueError("Received cursor is invalid.")
++ raise GraphQLError("Received cursor is invalid.")
+ filter_kwargs = (
+ _prepare_filter(cursor, sorting_fields, sorting_direction) if cursor else Q()
+ )
+ qs = qs.filter(filter_kwargs)
+ qs = qs[:end_margin]
- print(end_margin)
- print(qs)
+ edges, page_info = _get_edges_for_connection(edge_type, qs, args, sorting_fields)
+
+ return connection_type(edges=edges, page_info=page_info_type(**page_info),)
class NonNullConnection(Connection):
diff --cc saleor/graphql/core/fields.py
index 49ed12bf17,e558b67184..8afc293823
--- a/saleor/graphql/core/fields.py
+++ b/saleor/graphql/core/fields.py
@@@ -158,11 -154,11 +160,11 @@@ class FilterInputConnectionField(Prefet
first = args.get("first")
last = args.get("last")
-- if enforce_first_or_last:
-- assert first or last, (
-- "You must provide a `first` or `last` value to properly "
-- "paginate the `{}` connection."
-- ).format(info.field_name)
++ if enforce_first_or_last and not (first or last):
++ raise GraphQLError(
++ f"You must provide a `first` or `last` value to properly paginate "
++ f"the {info.field_name} connection."
++ )
if max_limit:
if first:
diff --cc saleor/graphql/plugins/sorters.py
index 0000000000,522494b2ad..9f7a0cc1dd
mode 000000,100644..100644
--- a/saleor/graphql/plugins/sorters.py
+++ b/saleor/graphql/plugins/sorters.py
@@@ -1,0 -1,50 +1,50 @@@
+ from typing import TYPE_CHECKING, List, Optional
+
+ import graphene
+
+ from ..core.types import SortInputObjectType
+
+ if TYPE_CHECKING:
+ # flake8: noqa
+ from ...plugins.base_plugin import BasePlugin
+
+
+ def sort_plugins(
+ plugins: List["BasePlugin"], sort_by: Optional[dict]
+ ) -> List["BasePlugin"]:
+ sort_reverse = sort_by.get("direction", False) if sort_by else False
+ sort_field = (
+ sort_by.get("field", PluginSortField.NAME) if sort_by else PluginSortField.NAME
+ )
+ if sort_field == PluginSortField.IS_ACTIVE:
+ plugins = sorted(
+ plugins,
+ key=lambda p: (not p.active if sort_reverse else p.active, p.PLUGIN_NAME),
+ )
+ else:
+ plugins = sorted(plugins, key=lambda p: p.PLUGIN_NAME)
+ if sort_reverse:
+ plugins = list(reversed(plugins))
+ return plugins
+
+
+ class PluginSortField(graphene.Enum):
- NAME = "name"
- IS_ACTIVE = "active"
++ NAME = ["name"]
++ IS_ACTIVE = ["active", "name"]
+
+ @property
+ def description(self):
+ # pylint: disable=no-member
+ descriptions = {
+ PluginSortField.NAME.name: "name",
+ PluginSortField.ACTIVE.name: "activity status",
+ }
+ if self.name in descriptions:
+ return f"Sort plugins by {descriptions[self.name]}."
+ raise ValueError("Unsupported enum value: %s" % self.value)
+
+
+ class PluginSortingInput(SortInputObjectType):
+ class Meta:
+ sort_enum = PluginSortField
+ type_name = "plugins"
diff --cc saleor/order/migrations/0083_merge_20200421_0529.py
index 0000000000,0000000000..fd0e77ef74
new file mode 100644
--- /dev/null
+++ b/saleor/order/migrations/0083_merge_20200421_0529.py
@@@ -1,0 -1,0 +1,13 @@@
++# Generated by Django 3.0.5 on 2020-04-21 10:29
++
++from django.db import migrations
++
++
++class Migration(migrations.Migration):
++
++ dependencies = [
++ ("order", "0082_fulfillmentline_stock"),
++ ("order", "0081_merge_20200309_0952"),
++ ]
++
++ operations = []
diff --cc saleor/product/models.py
index 4f13861c97,0933a56333..08f2c3eff2
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@@ -5,10 -5,9 +5,9 @@@ from django.conf import setting
from django.contrib.postgres.aggregates import StringAgg
from django.contrib.postgres.fields import JSONField
from django.db import models
-from django.db.models import Case, Count, F, FilteredRelation, Q, When
+from django.db.models import Case, Count, F, FilteredRelation, Q, Value, When
from django.urls import reverse
from django.utils.encoding import smart_text
- from django.utils.html import strip_tags
from django.utils.text import slugify
from django_measurement.models import MeasurementField
from django_prices.models import MoneyField
diff --cc tests/api/pagination/test_core.py
index 0000000000,fe2218b717..9eb3d23f28
mode 000000,100644..100644
--- a/tests/api/pagination/test_core.py
+++ b/tests/api/pagination/test_core.py
@@@ -1,0 -1,237 +1,221 @@@
+ import math
+
+ import graphene
+ import pytest
+
+ from saleor.graphql.core.connection import CountableDjangoObjectType
+ from saleor.graphql.core.fields import FilterInputConnectionField
+
+ from .models import Book
+
+
+ class BookType(CountableDjangoObjectType):
+ class Meta:
+ model = Book
+
+
+ class Query(graphene.ObjectType):
+ books = FilterInputConnectionField(BookType)
+
+
+ schema = graphene.Schema(query=Query)
+
+
+ @pytest.fixture
+ def books(db):
+ books = [Book(name=f"Book{index}") for index in range(24)]
+ return Book.objects.bulk_create(books)
+
+
+ QUERY_PAGINATION_TEST = """
+ query BooksPaginationTest($first: Int, $last: Int, $after: String, $before: String){
+ books(first: $first, last: $last, after: $after, before: $before) {
+ edges {
+ node {
+ name
+ }
+ }
+ pageInfo{
+ startCursor
+ endCursor
+ hasNextPage
+ hasPreviousPage
+ }
+ }
+ }
+ """
+
+
+ @pytest.mark.parametrize("page_size", [1, 5, 8, 25])
+ def test_pagination_forward(page_size, books):
+ end_cursor = None
+ has_next_page = True
+ object_count = 0
+ queries_count = 0
+ while has_next_page:
+ variables = {"first": page_size, "after": end_cursor}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ has_next_page = page_info["hasNextPage"]
+ end_cursor = page_info["endCursor"]
+ object_count += len(content["books"]["edges"])
+ queries_count += 1
+ assert object_count == len(books)
+ assert queries_count == math.ceil(len(books) / page_size)
+
+
+ @pytest.mark.parametrize("page_size", [1, 5, 8, 25])
+ def test_pagination_backward(page_size, books):
+ start_cursor = None
+ has_previous_page = True
+ object_count = 0
+ queries_count = 0
+ while has_previous_page:
+ variables = {"last": page_size, "before": start_cursor}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ has_previous_page = page_info["hasPreviousPage"]
+ start_cursor = page_info["startCursor"]
+ object_count += len(content["books"]["edges"])
+ queries_count += 1
+ assert object_count == len(books)
+ assert queries_count == math.ceil(len(books) / page_size)
+
+
+ def test_pagination_order(books):
+ page_size = len(books)
+
+ variables = {"first": page_size, "after": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ edges_forward = content["books"]["edges"]
+
+ variables = {"last": page_size, "before": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ edges_backward = content["books"]["edges"]
+
+ assert edges_forward == edges_backward
+
+
+ def test_pagination_previous_page_using_last(books):
+ page_size = 5
+
+ variables = {"first": page_size, "after": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ first_page_edges_forward = content["books"]["edges"]
+ first_page_info_forward = content["books"]["pageInfo"]
+
+ variables = {"first": page_size, "after": first_page_info_forward["endCursor"]}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ second_page_info = content["books"]["pageInfo"]
+
+ variables = {"last": page_size, "before": second_page_info["startCursor"]}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ first_page_edges_backward = content["books"]["edges"]
+
+ assert first_page_edges_forward == first_page_edges_backward
+
+
+ def test_pagination_forward_first_page_info(books):
+ variables = {"first": 5, "after": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ assert page_info["hasNextPage"]
+ assert page_info["hasPreviousPage"] is False
+
+
- reason="""Currently, page info has the bug, new pagination fixing it.
- We should uncomment this test in PR #5149."""
-)
+ def test_pagination_forward_middle_page_info(books):
+ page_size = 5
+
+ variables = {"first": page_size, "after": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ end_cursor = content["books"]["pageInfo"]["endCursor"]
+
+ variables = {"first": page_size, "after": end_cursor}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ assert page_info["hasNextPage"]
+ assert page_info["hasPreviousPage"]
+
+
- reason="""Currently, page info has the bug, new pagination fixing it.
- We should uncomment this test in PR #5149."""
-)
+ def test_pagination_forward_last_page_info(books):
+ page_size = 20
+
+ variables = {"first": page_size, "after": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ end_cursor = content["books"]["pageInfo"]["endCursor"]
+
+ variables = {"first": page_size, "after": end_cursor}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ assert page_info["hasNextPage"] is False
+ assert page_info["hasPreviousPage"]
+
+
+ def test_pagination_backward_first_page_info(books):
+ variables = {"last": 5, "before": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ assert page_info["hasNextPage"] is False
+ assert page_info["hasPreviousPage"]
+
+
- reason="""Currently, page info has the bug, new pagination fixing it.
- We should uncomment this test in PR #5149."""
-)
+ def test_pagination_backward_middle_page_info(books):
+ page_size = 5
+
+ variables = {"last": 5, "before": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ start_cursor = content["books"]["pageInfo"]["startCursor"]
+
+ variables = {"last": page_size, "before": start_cursor}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ assert page_info["hasNextPage"]
+ assert page_info["hasPreviousPage"]
+
+
- reason="""Currently, page info has the bug, new pagination fixing it.
- We should uncomment this test in PR #5149."""
-)
+ def test_pagination_backward_last_page_info(books):
+ page_size = 20
+
+ variables = {"last": page_size, "before": None}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ start_cursor = content["books"]["pageInfo"]["startCursor"]
+
+ variables = {"last": page_size, "before": start_cursor}
+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)
+ assert not result.errors
+ content = result.data
+ page_info = content["books"]["pageInfo"]
+ assert page_info["hasNextPage"]
+ assert page_info["hasPreviousPage"] is False