-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
name property in @Field does not work when used with @ArgsType #263
Comments
The But using |
Ok fair enough, if it's not meant for that then it probably shouldn't be done using
Now I am not able to switch from |
Yes - you can declare your function as: declare function fooBar(foo: string, bar: number); And then call it with your variables of different names: declare const foo: number;
declare const bar: string;
fooBar(bar, foo); With objects you have to map the original Why you can't just stick with 1:1 mapping between the names? Different names just make things harder to debug (I send |
Of course I can, but this would contradict a design decision that's been made in the application I'm working on. In the datebase and code, we're using integer IDs, but these are never shown to the outside world, for example because of security reasons. Another, textual ID (slug) is calculated and exposed to the outside, but to the outside this slug is called I will probably either stick to
but this is more error prone as a programmer might forget to put this mapping in a resolver function one day and another programmer might confuse an id for a slug. You could say that this issue is more of a nice-to-have than a need-to-have, and I would agree. But I do think there are more use cases in which one might want to have different namings for variables in one's code than in an API that is exposed to the outside world. |
I agree that it may be a useful feature so I will try to implement it with a performance impact in mind (detect if there's any mapping and if not, just skip it). But it's a more feature than a bug and it has lower prority that the missing GraphQL features, so it also need the new pipeline #183 to have access to built metadata. |
Describe the bug
I am trying to combine the arguments to one of my resolver's functions by using a class that I annotate with
@ArgsType()
. Since the name I want to expose is different in one case from the name I want to use internally, For this I am using thename
property for one of my fields, which has worked fine so far in my entities (annotated@ObjectType
). However, whereasname
does change the name that is exposed to the outside, it also changes the name of the property to which the incoming value is assigned.To Reproduce
Using the following code:
Calling my resolver shows the log
{"id": "my-id"}
. This looks like a bug to me, because the typeDeleteOrganizationArgs
does not have a property id.Expected behavior
I expect
args
to be equal to{"slug": "my-id"}
Enviorment (please complete the following information):
The text was updated successfully, but these errors were encountered: