Skip to content

Commit

Permalink
Allow filters to be deep and have access to OR, AND, NOT
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenrys committed Dec 30, 2022
1 parent 3f096a0 commit 8c54451
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/generator/templates/schema.gql.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ enum OrderByArg {
{% endif %}

input {{ model.name }}Filter {
some: {{ model.name }}ScalarWhereInput
every: {{ model.name }}ScalarWhereInput
none: {{ model.name }}ScalarWhereInput
some: {{ model.name }}WhereInput
every: {{ model.name }}WhereInput
none: {{ model.name }}WhereInput
}

{#
input {{ model.name }}RelationFilter {
{% for field in model.fields -%}
{% if not field.relation -%}
Expand All @@ -77,11 +77,17 @@ enum OrderByArg {
{{ field.name }}: StringFilter
{% endif -%}
{% endif -%}
{% else -%}
{% if field.relation.kind === "one" -%}
{{ field.name }}: {{ field.relation.type }}WhereInput
{% else -%}
{{ field.name }}: {{ field.relation.type }}Filter
{% endif -%}
{% endif -%}
{% endfor %}
}
} #}

input {{ model.name }}ScalarWhereInput {
{# input {{ model.name }}ScalarWhereInput {
{% for field in model.fields -%}
{% if not field.relation -%}
{% if field.isList -%}
Expand All @@ -103,7 +109,7 @@ enum OrderByArg {
{% endif -%}
{% endif -%}
{% endfor %}
}
} #}

input {{ model.name }}WhereInput {
OR: [{{ model.name }}WhereInput]
Expand All @@ -130,7 +136,7 @@ enum OrderByArg {
{% endif -%}
{% else -%}
{% if field.relation.kind === "one" -%}
{{ field.name }}: {{ field.relation.type }}RelationFilter
{{ field.name }}: {{ field.relation.type }}WhereInput
{% else -%}
{{ field.name }}: {{ field.relation.type }}Filter
{% endif -%}
Expand Down

0 comments on commit 8c54451

Please sign in to comment.