Shopify / Shopify/shopify-api-ruby

Suggestion: Make it easier to identify or bypass only submitting dirty attributes on update

Open
#1,227 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.1k
Forks
484
PR merge metrics
No merged PRs in 30d

Description

This feature to only send changed fields has tripped me up a few times and can be difficult to identify.

The problem I've ran into is when the object state hasn't changed and you call save it will still do the put request with an empty payload and you end up with an error with something like {"errors":{"metafield":"Required parameter missing or invalid"} which isn't very clear about the problem. As far as I can tell there isn't a method that I can use to inspect the object to decide if I need to save or not.

If this functionality is really important what do you think about a few additional features to make it easier to work with or bypass, such as:

  1. Allow bypassing the dirty attributes check and sending all attributes on save. Maybe something like save(only_changed: false)
  2. Provide a method that we can use to inspect the object to see if there are changes so we can skip the save call if we want. Something like changed? or dirty? maybe?

It would also be great if an error or warning of some sort was returned if the payload you are submitting is empty.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the dirty-attributes behavior introduced in PR 1149 and trace the save path that sends the PUT request. Define which proposed behavior is in scope—bypassing dirty checks, inspecting changes, or reporting empty payloads—and consider the issue complete when the selected behavior is specified with a clear way to verify it.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.