Mutation FIELDS_CHANGE with connection field

I am trying to understand how Relay works.

1.) Let's say I have an UpdateProductMutation (type FIELDS_CHANGE) that updates the fields of a single product, i.e. "title", "description", etc. I can send a mutation with these field changes and work, (Let's say the product is here Banana)

2.) Now I am adding the product_categories field of type ProductCategoryConnection to the type of product. And in the UpdateProductMutation mutation , I send an array of catIds as an additional input property of the mutation. (i.e. catIds: {type: new GraphQLList(GraphQLID)}). It also mutates the product successfully with the product_categories field.

3.) To make it easier to follow, for example, Bananathe product had Fruitand Yellowcategories. And I added Healthyin step 2.)

4) The problem is that if I made the page request Healthyto step 2. And Relay is already in the cache store, again visiting the page Healthyfrom step 2 again shows no related products Banana.

This is my mutational config and bold request.

getFatQuery() {
  return Relay.QL`
    fragment on UpdateProductPayload {
      updatedProduct,
    }
  `;
}

getConfigs() {
  console.warn('getConfigs', this.props);
  return [{
    type: 'FIELDS_CHANGE',
    fieldIDs: {updatedProduct: this.props.id},
  }];
}

, . , FIELDS_CHANGE , , . , . ( ). , RANGE_ADD RANGE_DELETE (, "title", "description" ..). catIds RANGE_ADD RANGE_DELETE, .

, ?

+4

Source: https://habr.com/ru/post/1621981/


All Articles