-
Notifications
You must be signed in to change notification settings - Fork 152
Propose renaming id_v2 to something more permanent, and change type #396
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
Conversation
3ff6ceb
to
536d04d
Compare
536d04d
to
54174a6
Compare
We will have two naming approaches in the system for some time. Since the proposed name
It looks like the question boils down to which pair is less confusing. In my personal opinion the second option is less confusing because it follows the same versioning principle we already accepted for all fields. It is also intuitive. If I was a developer seeing |
@paliarush Thank you for the feedback!
IMHO, there is one additional consideration here: how this field looks in the schema in 5 years? I would hope that 5 years from now, we have one, well-known field to represent the ID of an object type (rather than
Unlike other fields that are specific to their domain objects, IDs are a very general API feature. I'm of the opinion that this should be the last time we change this field name. Is there a scenario where we ever see ourselves having an
I would (respectfully) argue that |
From the history of Magento we can assume that deprecated fields may stay there for more than 5 years. I am not saying that the name Additionally, there is a chance of One solution could be to rename all ids in the system to |
Totally separate (likely hours long) discussion, but sounds like we need some more general guidelines for how we handle deprecations (remove after X versions, X years, X decades, etc). But I know better than to try and address that in this ticket!.
I think it's safe to say that we both agree that using almost any name besides
This is the part that I'm skeptical about, and really the driving motivation behind this PR. Can you give some examples of semantic changes that would lead to us introduce another ID field on an object? I think this is an important discussion to have.
Yep! Typically just passing in a callback with the signature |
Let's have a little broader discussion to rename all IDs to |
Sounds good to me! |
Additional reading that's helpful:
Our API currently doesn't support the ability to lookup an arbitrary entity by ID, which is desirable for some GraphQL clients. A consistent ID/type will open up the option to support this in the future. |
@DrewML - I won't be able to make the discussion, but had an additional point I wanted to make sure was represented. On the same theme as automatic caching using
I don't know if there was still an argument for just allowing backwards incompatible changes to As a moonshot alternative, if we're going to introduce a new ID field, I propose we do it across all types and deprecate |
I think everything is on the table. IMHO this is the best idea if the only motivation is consistency. But, I suspect we might not be able to reach consensus on a breaking change of that size.
That's definitely what I'm advocating for 👍 1 well-known ID field, for every entity. |
Meeting scheduled today for us all to discuss. Here's a quick summary we can review when we kick off the meeting: Summary of problem so far:
Here is what has been discussed in this PR so far:
|
We had a productive meeting, with some outcomes! Attendees: Outcomes:
Action Items:
|
Regarding these items:
Update: Definitely a breaking change, per feedback given in graphql/graphql-js#2711. query GetSomeEntity($var: String!) {
field1(id: $var) # If "id" is an ID type, this operation would break because of the variable
} Will think about alternative paths - most obvious one is deprecating the existing queries/mutations that take a Original Comment Details (Incorrect)
I made a quick POC GraphQL server using the [GraphQL reference implementation](https://github.com/graphql/graphql-js), and tested changing a field argument from `String` or `Int` to `ID`. I ran a sample query both before and after the change, and verified the query still works.
Test SchemasBeforetype Query {
field1(arg1: String): Int
field2(arg1: Int): Int
} Aftertype Query {
field1(arg1: ID): Int
field2(arg1: ID): Int
} Test Query# This query works with both the "before" and "after" schema
{
field1(arg1: "foo")
field2(arg1: 1)
} This works because of the Input Coercion rules for
http://spec.graphql.org/June2018/#sec-ID Breaking Change DetectionThe GraphQL reference implementation includes a tool to find breaking changes in a schema, and it currently flags this as a breaking change. To make sure I'm not overlooking anything, I've started up a discussion on that repo: |
This (if approved) impacts an in-flight PR: magento/magento2#28210
These changes are based on discussions I've had with @prabhuram93 and @nrkapoor.
There were a few concerns I wanted to address:
We should be using the
ID
type for IDs, because we don't want clients using them for anything but lookups. Mentioned in a separate design documentThe document mentioned that
id_v2
was a temporary field until we start using UUIDs. If we use theID
type, though, we shouldn't need a temporary field. If a client deploys a new version of the GraphQL API (after we switch from base64 >> uuid) and a client has cache entries for the old IDs, those old entries just won't be looked up in the client-side cache anymore. No loss/corruption should happenI believe this matches the vision for every entity to have a globally unique ID, but with less downstream changes for clients. Please correct me if I'm wrong!
@nrkapoor and I discussed various names for the field. I've gone with
uid
in the PR, but happy to change if we can reach consensus on a different name. Here's the names we discussed:uuid
: Bad because UUID is a specific encoding algorithm, and a client should not care about thatgid
: "Global Identifier"uid
: "Unique Identifier"_id
: Just kind of uglyidentifier
: Verbose, but accurateNote: It's worth knowing that popular GraphQL client libraries (Apollo/urql) have default cache configurations that look for the field name
id
or_id
on Object Types. Whatever new field we choose, we should be consistent going forward, as each headless solution will now need to customize their client to use this new cache key. See https://www.apollographql.com/docs/react/caching/cache-configuration/#custom-identifiers