Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Propose updates to GraphQL extensibility doc #404
base: master
Are you sure you want to change the base?
Propose updates to GraphQL extensibility doc #404
Changes from 1 commit
4085808
346bd5c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say we must always use
input
because we never know how Magento is/will be extended.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's very likely you're right here. I have a tendency to try and leave a little wiggle room 😄
Do you want to make any exception for the case of looking something up by ID? I think in the case of a field like
Query.productByID
(as an example) it might be nice to just take theID
, and if folks want to add arguments to a unary field, they just have to introduce a new query instead.If you think this isn's worth it, happy to go forward with your suggested change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inability to extend is the reason why I don't like
byId
methods. I would useinput
everywhere. Simper rule - less bugs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does every query need to be infinitely extensible? Can you describe a scenario where a
Query.fooByID
field would need to have its arguments extended, and where that would make more sense than adding a new query? Both a new argument and a new field would require changes for a headless UI to consume already, so it's not less work for the client.I think, for single entity lookups (not queries for collections) there aren't many scenarios where it would make sense to take more than an
ID
as input. Most other arguments you'd add to that method would likely change the behavior as well (breaking change).Please correct me if I'm wrong, but it seems like a lot of the reasons to add more arguments to a field might be a sign that, for simple cases like this, the field is trying to do too much.
There's also the question of naming - anytime we use a field like
Query.product
instead ofQuery.productByID
, we're using a more generic name that's likely to be overloaded later for either uses, leading to things like deprecations and_v2
fields. Explicit names and granular fields in this case (imo) kind of force the query to be a bit more focused.Isn't it the opposite in this case? Adding an argument to an existing field adds branching to a resolver, and a developer needs to take great care to make sure that logic does not impact any existing queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opinion against
byId
, but would really like to haveinput
mandatory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that 👍 Will make changes