You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Don’t accept an object for parameters named id (and the return is of the same type) #4191
If you already have an object it doesn’t make sense to use these fields to get the same object. So these fields only make sense if you have an ID somehow, and need to get the object they represent.
Note: It’s not clear when you’d need these fields in a codegen client. IDs are an implementation detail.
Solution
Replace all ID inputs with object references, unless the argument name is id and the field’s return type is that object type.
Rename outliers
That’s a good rule of thumb that is future proof, because there’s two outliers with id param names that I think should be renamed, but there can be other cases in the future.
type Git {
- commit(id: string)+ commit(hash: string)
}
type Container {
- withRootfs(id: DirectoryID!): Container!+ withRootfs(source: DirectoryID!): Container!
}
Note: Git.commit is harmless since it’s not asking for an ID type, but I still think it should be renamed.
Somehow I got confused with the top-level selectors:
Top-level selectors (e.g. File(id FileID)) become weird (File(id *File)) -- if you already have the file, what's the point of having a function to look it up? I've kept them as File(id FileID)
In #3870 I just replaced every ID scalar with an object. Later, in #3936, I realized these fields with an id parameter looked weird by passing an object, so I added a union:
# beforedeffile(self, id: FileID) ->File: ...
# after hiding IDsdeffile(self, id: File) ->File: ...
# follow-up to bring back ID heredeffile(self, id: FileID|File) ->File: ...
Activity