-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Introduce support for Universally Unique Identifiers #2749
Conversation
Hi! So can you verify that with your PR someone can still override this type and use https://github.com/google/uuid ? I would note that google/uuid is still more widely used than gofrs/uuid per this: I don't mind picking a default implementation, but I would like to provide a working example that successfully overrides with an alternative since there are a number of popular choices that people are already using. This is how sqlc works: https://docs.sqlc.dev/en/stable/reference/config.html#type-overriding |
I will have to figure it out how to test that 😬
The Google implementation is the most popular indeed, but it looks like it's not actively maintained. On the other hand, what are those failures in the pipeline? As far as I can tell it's complaining about |
Nevermind. I was lurking in some other pull requests, and I saw the |
If the relevant changes are done in |
I'm sorry, but I'm kind of confused by the wording of your question. Can you please rephrase that? This PR is just like PR #2751 but here the choice is github.com/gofrs/uuid instead of there it is github.com/google/uuid Many people will have already chosen one of those two (or something else) and so will have something like this in their models:
UUID:
model:
- github.com/google/uuid Please add to this PR a similar example that verifies that people can still override the default choice after your PR is applied. |
I didn't realize there was another pull request for the same work. I'm fine with either |
Actually, yours was better quality, and it passed the tests! 😞 |
I have another pull request to be able to use As it stands, the type CustomType {
id: ID!
uuidID: UUID!
} The end goal is to be able to use models:
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.UUID # Probably this is not even necessary |
return Null | ||
} | ||
return WriterFunc(func(w io.Writer) { | ||
_, _ = io.WriteString(w, t.String()) |
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.
writeQuotedString(w, t.String()) ?
uuid type marsher is "00000000-0000-0000-0000-00 0000000000"
must Quoted
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 fully understand why is that needed here. I think that might be the case for arbitrary string values that should be double-quoted because they could have escaped/control characters and non-printable ones, but the uuid.UUID
will never have those.
* add uuid type * add uuid example * add uuid scalar doc * strconv.Quote * Apply suggestions from code review * fix * Adjust documentation to match PR #2749 Signed-off-by: Steve Coffman <steve@khanacademy.org> --------- Signed-off-by: Steve Coffman <steve@khanacademy.org> Co-authored-by: Steve Coffman <StevenACoffman@users.noreply.github.com> Co-authored-by: Steve Coffman <steve@khanacademy.org>
I really appreciate this contribution, as it had excellent documentation (and great tests!). I ended up applying your documentation and using #2751 as it used It took a long time to discuss (argue) about which PR to merge, and we were pretty conflicted, so I'm very sorry for the delay (and that we did not pick merging this PR as is). I hope that doesn't dissuade you from future contributions, as this was excellent quality. |
A Universally Unique Identifier (UUID) is a 128-bit used for information in computer systems. The term Globally Unique Identifier (GUID) is also used, mostly in Microsoft systems.
Because Go (still) does not have built-in support for UUID types, module
gofrs/uuid
is imported. It's the most complete, correct (and starred) module nowadays.This pull request introduces support for Universally Unique Identifiers (UUID) within
gqlgen
.I have:
Closes #2748