Skip to content

Add document with suggestions for ID fields #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2020
Merged

Add document with suggestions for ID fields #395

merged 3 commits into from
Jul 14, 2020

Conversation

DrewML
Copy link
Contributor

@DrewML DrewML commented Jul 8, 2020

- Include info in the client-facing description describing how the field is encoded/decoded (should be opaque)
- Example: The client shouldn't know if an `ID` is a base64-encoded integer
- Use `String` or `Int` type

Copy link
Contributor

@tjwiebell tjwiebell Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels odd to include this, but SelectedConfigurableOption violates this rule, and causes odd behavior with automatic caching. This id field is based on ConfigurableProductOption.id, which is not unique across all responses. Doesn't hurt to be explicit, but consider this optional.

Suggested change
- Use an ID value you cannot guarantee is unique across all responses

Copy link
Contributor Author

@DrewML DrewML Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This id field is based on ConfigurableProductOption.id, which is not unique across all responses.

Whoa. Just to make sure I'm reading this right, you're saying that I can get 2 different ConfigurableProductOption types from the API that collide on the id field, but hold different data in the other fields?

Copy link
Contributor

@tjwiebell tjwiebell Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! We ended up keying on value_id instead, which I didn't consider might also not be unique 😶

Screen Shot 2020-07-08 at 4 31 47 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which I didn't consider might also not be unique

Oh noooooo. Well, you've definitely highlighted that we've got some work to do, but trending in the right direction!

Going to push an update to the document

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this under Do Not, let me know if you have suggestions to tweak the wording:

Use duplicate IDs across a concrete type. In other words, if the client wants to produce a cache key, the concetenation of a __typename + id field should always be unique.

@DrewML
Copy link
Contributor Author

DrewML commented Jul 9, 2020

Added the following under Do based on feedback from @prabhuram93:

Make the ID field non-nullable (syntax: ID!)

@DrewML
Copy link
Contributor Author

DrewML commented Jul 14, 2020

Never have we reached consensus this easily 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants