adding a Comparison scalar and surfacing it in definition block for S…#260
Merged
adding a Comparison scalar and surfacing it in definition block for S…#260
Conversation
kgajera
reviewed
May 20, 2022
Contributor
kgajera
left a comment
There was a problem hiding this comment.
Because we are using the new compare type in the StringFilter, I'm wondering if this change makes sense. What are the use cases where I would want to pass a number, date, etc. when using a filter for "strings":
export const StringFilter = inputObjectType({
name: 'StringFilter',
description: 'A way to filter string fields. Meant to pass to prisma where clause',
definition(t) {
t.string('contains');
t.string('endsWith');
t.string('equals');
t.compare('gt');
t.compare('gte');
t.list.nonNull.string('in');
t.compare('lt');
t.compare('lte');
t.list.nonNull.string('notIn');
t.string('startsWith');
},
});Does it make more sense for us to define a filter for each of our types like below so we don't sacrifice type safety:
export const StringFilter = inputObjectType({
name: 'StringFilter',
description: 'A way to filter string fields. Meant to pass to prisma where clause',
definition(t) {
t.string('contains');
t.string('endsWith');
t.string('equals');
t.string('gt');
t.string('gte');
t.list.nonNull.string('in');
t.string('lt');
t.string('lte');
t.list.nonNull.string('notIn');
t.string('startsWith');
},
});
export const NumberFilter = inputObjectType({
name: 'NumberFilter',
description: 'A way to filter number fields. Meant to pass to prisma where clause',
definition(t) {
t.int('equals');
t.int('gt');
t.int('gte');
t.list.nonNull.int('in');
t.int('lt');
t.int('lte');
t.list.nonNull.int('notIn');
},
});
export const DateFilter = inputObjectType({
name: 'DateFilter',
description: 'A way to filter date fields. Meant to pass to prisma where clause',
definition(t) {
t.date('equals');
t.date('gt');
t.date('gte');
t.list.nonNull.date('in');
t.date('lt');
t.date('lte');
t.list.nonNull.date('notIn');
},
});
Collaborator
|
Curious about the thoughts for the comment above as well. |
Contributor
Author
|
True. I think that approach makes more sense. I'll refactor. |
…tringFilter input type
3c66557 to
6b89083
Compare
kgajera
approved these changes
Jun 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding updates that allow for comparison operators
gte,gt,lte,ltto accept eitherstring,number, orobjectwithout throwing TS errorsChanges
Comparisoncustom scalar to be used with comparison operatorsgte,gt,lte,ltcomparemethod in definition block usingasNexusMethodChecklist
Fixes #xxx