-
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
#2794 is bug #2795
Comments
type Todo {
id: ID!
text: String!
done: Boolean!
uid: UUID!
puid:UUID
}
type Query {
todos: [Todo!]!
}
go code func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
return []*model.Todo{
{ID: "1", Text: "hello", Done: true, UID: uuid.New(), Puid: &uuid.UUID{}},
{ID: "2", Text: "world", Done: false, UID: uuid.New(), Puid: nil},
}, nil
} #2794 return
ok result (v v0.17.37 )
|
if need I can commit PR to fix #2794 |
@0x221A Can you please comment on this? |
@StevenACoffman For me the user wants to return a zero value uuid instead of |
Using the pointer of uuid is the other approach but I'm concerned when using it with SQL scan interface or an unexpected nil address panic. |
show your code, let me see see. |
@0x221A look this func (uuid *UUID) Scan(src interface{}) error {
switch src := src.(type) {
case nil:
return nil // look this
case string:
// if an empty UUID comes from a table, we return a null UUID
if src == "" {
return nil
}
// see Parse for required string format
u, err := Parse(src)
if err != nil {
return fmt.Errorf("Scan: %v", err)
}
*uuid = u
case []byte:
// if an empty UUID comes from a table, we return a null UUID
if len(src) == 0 {
return nil
}
// assumes a simple slice of bytes if 16 bytes
// otherwise attempts to parse
if len(src) != 16 {
return uuid.Scan(string(src))
}
copy((*uuid)[:], src)
default:
return fmt.Errorf("Scan: unable to scan type %T into UUID", src)
}
return nil
} |
#2794
no ... I think this is bug....
uuid is value type , like int.
default value is zero value ( uuid.Nil), in GraphQL is UUID!
nil ('null") is *uuid.UUID in Graphql is UUID. ( no !)
so this is bug!
@StevenACoffman @0x221A
Originally posted by @it512 in #2794 (comment)
The text was updated successfully, but these errors were encountered: