Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix apollo cache
dominik-zeglen944befd27e52
diff --git a/saleor/static/dashboard-next/collections/mutations.ts b/saleor/static/dashboard-next/collections/mutations.tsindex 2e381351f7..89337f0f20 100644--- a/saleor/static/dashboard-next/collections/mutations.ts+++ b/saleor/static/dashboard-next/collections/mutations.ts@@ -1,7 +1,10 @@import gql from "graphql-tag";import { TypedMutation } from "../mutations";-import { collectionDetailsFragment } from "./queries";+import {+ collectionDetailsFragment,+ collectionProductFragment+} from "./queries";import {CollectionAssignProduct,CollectionAssignProductVariables@@ -81,6 +84,7 @@ export const TypedCollectionUpdateWithHomepageMutation = TypedMutation<>(collectionUpdateWithHomepage);const assignCollectionProduct = gql`+ ${collectionProductFragment}mutation CollectionAssignProduct($collectionId: ID!$productId: ID!@@ -96,14 +100,7 @@ const assignCollectionProduct = gql`products(first: $first) {edges {node {- id- isPublished- name- productType {- id- name- }- thumbnailUrl+ ...CollectionProductFragment}}pageInfo {diff --git a/saleor/static/dashboard-next/collections/queries.ts b/saleor/static/dashboard-next/collections/queries.tsindex 24c7e71cc7..de9c345707 100644--- a/saleor/static/dashboard-next/collections/queries.ts+++ b/saleor/static/dashboard-next/collections/queries.ts@@ -33,7 +33,26 @@ export const collectionDetailsFragment = gql`descriptionseoDescriptionseoTitle+ isPublisheds+ }+`;++// This fragment is used to make sure that product's fields that are returned+// are always the same - fixes apollo cache+// https://github.com/apollographql/apollo-client/issues/2496+// https://github.com/apollographql/apollo-client/issues/3468+export const collectionProductFragment = gql`+ fragment CollectionProductFragment on Product {+ idisPublished+ name+ productType {+ id+ name+ }+ thumbnail {+ url+ }}`;@@ -70,6 +89,7 @@ export const TypedCollectionListQuery = TypedQuery<export const collectionDetails = gql`${collectionDetailsFragment}+ ${collectionProductFragment}query CollectionDetails($id: ID!$first: Int@@ -82,16 +102,7 @@ export const collectionDetails = gql`products(first: $first, after: $after, before: $before, last: $last) {edges {node {- id- isPublished- name- productType {- id- name- }- thumbnail {- url- }+ ...CollectionProductFragment}}pageInfo {@@ -115,12 +126,12 @@ export const TypedCollectionDetailsQuery = TypedQuery<>(collectionDetails);export const searchProducts = gql`+ ${collectionProductFragment}query SearchProducts($query: String!) {products(first: 5, query: $query) {edges {node {- id- name+ ...CollectionProductFragment}}}diff --git a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsxindex e2c4f4adc5..b5bcc29503 100644--- a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx+++ b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx@@ -103,7 +103,6 @@ export const CollectionDetails: React.StatelessComponent<context: "notification"})});- navigate(collectionUrl(id), true);}};