Ordering by fields omitted for inputs #237
Unanswered
jagged3dge
asked this question in
Q&A
Replies: 2 comments 1 reply
-
For now, I'm able to work around this by doing so:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Have you tried the extended input omit feature?
|
Beta Was this translation helpful? Give feedback.
1 reply
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
Hi all!
I'm in a quandary. I have a model with basic audit log fields
createdAt
,updatedAt
&deletedAt
.I do not want users to be able to input their values for these fields, hence I've defined these like so:
This is my GraphQL query:
If I want to retrieve brands in order of their
updatedAt
date in descending order, I cannot use the following variables with the above query:This query throws the following error:
I could write a custom resolver class that extends
BrandOrderByWithRelationInput
to resolve this.But I have plenty of models that will require this. Manually creating custom resolver classes for all the models is tedious and a maintenance nightmare.
Is there a simpler workaround?
Edit:
After careful thought, I see why the generator doesn't create the fields in the
XXXOrderByWithRelationInput
because they are marked to be omitted in all input args.However, considering that the
XXXOrderByWithRelationInput
class (and otherXXXOrderBy...
classes) is/are only used in queries, never in mutations, I propose that there must be some way to indicate that these fields should be allowed for ordering by.Just like
input: boolean
andoutput: boolean
, there could be an option:order: boolean
that would be checked only if a field is marked withinput: false
.If
input: false, order: true
, generator would enable the field in theXXXOrderBy...Input
class(es).If
input: false, order: false
(or onlyinput: false
), then the current process continues as is.Beta Was this translation helpful? Give feedback.
All reactions