Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DrewML
Copy link
Contributor

@DrewML DrewML commented Jul 17, 2020

Rendered Document

I noticed the extensibility document was missing some content while I was updating it with proposed solution from #400. This PR contains changes to address #400 and some additional guidelines we (mostly) already follow.

Feedback appreciated :)

Reviewers list populated with folks that commonly contribute to our schema.

design-documents/graph-ql/extensibility.md Outdated Show resolved Hide resolved
password: String!,
multi_factor_auth_token: String!
): GenerateCustomerTokenOutput!
If a query or mutation accepts (or will likely accept) > 1 argument, an Input Object should be used instead, and given the argument name `input`.
Copy link
Contributor

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.

Copy link
Contributor Author

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 the ID, 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.

Copy link
Contributor

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 use input everywhere. Simper rule - less bugs.

Copy link
Contributor Author

@DrewML DrewML Jul 22, 2020

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

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 of Query.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.

Simper rule - less bugs.

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.

Copy link
Contributor

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 have input mandatory.

Copy link
Contributor Author

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

Co-authored-by: Alex Paliarush <paliarus@adobe.com>
@DrewML DrewML requested review from melnikovi and removed request for danielrenaud August 27, 2020 16:48
@DrewML
Copy link
Contributor Author

DrewML commented Aug 27, 2020

@melnikovi @nrkapoor can y'all give this a review when you find time?

@melnikovi melnikovi added the needs update Author should update the proposal based on the feedback label Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-guild GraphQL needs update Author should update the proposal based on the feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants