Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Allow to inject cache hash suffix for graphql schema from env (#18202)
Lukasz Ostrowskib4a24028d58b
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.pyindex d0dce437dc..a64198a8b2 100644--- a/saleor/graphql/views.py+++ b/saleor/graphql/views.py@@ -563,6 +563,10 @@ def instantiate_middleware(middlewares):def generate_cache_key(raw_query: str) -> str:hashed_query = hashlib.sha256(str(raw_query).encode("utf-8")).hexdigest()++ if settings.GRAPHQL_CACHE_SUFFIX:+ return f"{saleor_version}-{hashed_query}-{settings.GRAPHQL_CACHE_SUFFIX}"+return f"{saleor_version}-{hashed_query}"diff --git a/saleor/settings.py b/saleor/settings.pyindex fdd54c9c2b..552fc5ed49 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -1077,6 +1077,10 @@ TELEMETRY_METER_CLASS = "saleor.core.telemetry.metric.Meter"# Disabled by default to prevent disruptions caused by unexpected unit conversion issuesTELEMETRY_RAISE_UNIT_CONVERSION_ERRORS = False+# Additional hash suffix, allowing to invalidate cached schema. In production usually we want this to be empty.+# For development envs, where schema may change often, it may be convenient to set it to e.g. commit hash value.+GRAPHQL_CACHE_SUFFIX = os.environ.get("GRAPHQL_CACHE_SUFFIX", "")+# Library `google-i18n-address` use `AddressValidationMetadata` form Google to provide address validation rules.# Patch `i18n` module to allows to override the default address rules.i18n_rules_override()