Skip to content

Commit

Permalink
refactor(filters): do not show orderBy in new filter parameter
Browse files Browse the repository at this point in the history
We want to separate filtering and ordering syntactically, so it doesn't
make sense to allow filtering in the filter[] list in the first place.
  • Loading branch information
David Vogt committed Oct 16, 2019
1 parent 916bd6a commit cbb8ac9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
1 change: 1 addition & 0 deletions caluma/core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def _get_or_make_field(name, filt):
filter_fields = {
name: _get_or_make_field(name, filt)
for name, filt in _filter_coll.filters.items()
if not isinstance(filt, OrderingFilter)
}

filter_fields["invert"] = graphene.Boolean(required=False, default=False)
Expand Down
19 changes: 6 additions & 13 deletions caluma/tests/snapshots/snap_test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
status: CaseStatus!
meta: GenericScalar
document: Document
workItems(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], status: WorkItemStatusArgument, task: ID, case: ID, orderBy: [WorkItemOrdering], filter: [WorkItemFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, addressedGroups: [String], documentHasAnswer: [HasAnswerFilterType], caseDocumentHasAnswer: [HasAnswerFilterType], caseMetaValue: [JSONValueFilterType]): WorkItemConnection
workItems(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], status: WorkItemStatusArgument, task: ID, case: ID, filter: [WorkItemFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, orderBy: [WorkItemOrdering], addressedGroups: [String], documentHasAnswer: [HasAnswerFilterType], caseDocumentHasAnswer: [HasAnswerFilterType], caseMetaValue: [JSONValueFilterType]): WorkItemConnection
parentWorkItem: WorkItem
}
Expand All @@ -134,7 +134,6 @@
createdByGroup: String
metaHasKey: String
metaValue: [JSONValueFilterType]
orderBy: [CaseOrdering]
documentForm: String
hasAnswer: [HasAnswerFilterType]
searchAnswers: [SearchAnswersFilterType]
Expand Down Expand Up @@ -407,7 +406,6 @@
createdByGroup: String
metaHasKey: String
metaValue: [JSONValueFilterType]
orderBy: [DocumentOrdering]
rootDocument: ID
hasAnswer: [HasAnswerFilterType]
searchAnswers: [SearchAnswersFilterType]
Expand Down Expand Up @@ -610,7 +608,6 @@
}
input FormFilterSetType {
orderBy: [FormOrdering]
slug: String
name: String
description: String
Expand Down Expand Up @@ -1036,13 +1033,13 @@
documentAsOf(id: ID!, asOf: DateTime!): HistoricalDocument
allDataSources(before: String, after: String, first: Int, last: Int): DataSourceConnection
dataSource(name: String, before: String, after: String, first: Int, last: Int): DataSourceDataConnection
allWorkflows(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], slug: String, name: String, description: String, isPublished: Boolean, isArchived: Boolean, orderBy: [WorkflowOrdering], filter: [WorkflowFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, search: String): WorkflowConnection
allTasks(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], slug: String, name: String, description: String, type: TaskTypeArgument, isArchived: Boolean, orderBy: [TaskOrdering], filter: [TaskFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, search: String): TaskConnection
allCases(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], workflow: ID, orderBy: [CaseOrdering], filter: [CaseFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, documentForm: String, hasAnswer: [HasAnswerFilterType], searchAnswers: [SearchAnswersFilterType], status: [CaseStatusArgument], orderByQuestionAnswerValue: String): CaseConnection
allWorkItems(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], status: WorkItemStatusArgument, orderBy: [WorkItemOrdering], filter: [WorkItemFilterSetType], documentHasAnswer: [HasAnswerFilterType], caseDocumentHasAnswer: [HasAnswerFilterType], caseMetaValue: [JSONValueFilterType], task: ID, case: ID, createdByUser: String, createdByGroup: String, metaHasKey: String, addressedGroups: [String]): WorkItemConnection
allWorkflows(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], slug: String, name: String, description: String, isPublished: Boolean, isArchived: Boolean, filter: [WorkflowFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, search: String, orderBy: [WorkflowOrdering]): WorkflowConnection
allTasks(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], slug: String, name: String, description: String, type: TaskTypeArgument, isArchived: Boolean, filter: [TaskFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, search: String, orderBy: [TaskOrdering]): TaskConnection
allCases(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], workflow: ID, filter: [CaseFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, orderBy: [CaseOrdering], documentForm: String, hasAnswer: [HasAnswerFilterType], searchAnswers: [SearchAnswersFilterType], status: [CaseStatusArgument], orderByQuestionAnswerValue: String): CaseConnection
allWorkItems(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], status: WorkItemStatusArgument, filter: [WorkItemFilterSetType], orderBy: [WorkItemOrdering], documentHasAnswer: [HasAnswerFilterType], caseDocumentHasAnswer: [HasAnswerFilterType], caseMetaValue: [JSONValueFilterType], task: ID, case: ID, createdByUser: String, createdByGroup: String, metaHasKey: String, addressedGroups: [String]): WorkItemConnection
allForms(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], orderBy: [FormOrdering], slug: String, name: String, description: String, isPublished: Boolean, isArchived: Boolean, filter: [FormFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, search: String, slugs: [String]): FormConnection
allQuestions(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], orderBy: [QuestionOrdering], slug: String, label: String, isRequired: String, isHidden: String, isArchived: Boolean, filter: [QuestionFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, excludeForms: [ID], search: String, slugs: [String]): QuestionConnection
allDocuments(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], form: ID, forms: [ID], search: String, id: ID, orderBy: [DocumentOrdering], filter: [DocumentFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, rootDocument: ID, hasAnswer: [HasAnswerFilterType], searchAnswers: [SearchAnswersFilterType]): DocumentConnection
allDocuments(before: String, after: String, first: Int, last: Int, metaValue: [JSONValueFilterType], form: ID, forms: [ID], search: String, id: ID, filter: [DocumentFilterSetType], createdByUser: String, createdByGroup: String, metaHasKey: String, orderBy: [DocumentOrdering], rootDocument: ID, hasAnswer: [HasAnswerFilterType], searchAnswers: [SearchAnswersFilterType]): DocumentConnection
allFormatValidators(before: String, after: String, first: Int, last: Int): FormatValidatorConnection
documentValidity(id: ID!, before: String, after: String, first: Int, last: Int): DocumentValidityConnection
node(id: ID!): Node
Expand Down Expand Up @@ -1078,7 +1075,6 @@
}
input QuestionFilterSetType {
orderBy: [QuestionOrdering]
slug: String
label: String
isRequired: String
Expand Down Expand Up @@ -1765,7 +1761,6 @@
metaHasKey: String
metaValue: [JSONValueFilterType]
search: String
orderBy: [TaskOrdering]
invert: Boolean
}
Expand Down Expand Up @@ -1900,7 +1895,6 @@
createdByGroup: String
metaHasKey: String
metaValue: [JSONValueFilterType]
orderBy: [WorkItemOrdering]
addressedGroups: [String]
documentHasAnswer: [HasAnswerFilterType]
caseDocumentHasAnswer: [HasAnswerFilterType]
Expand Down Expand Up @@ -1980,7 +1974,6 @@
metaHasKey: String
metaValue: [JSONValueFilterType]
search: String
orderBy: [WorkflowOrdering]
invert: Boolean
}
Expand Down
25 changes: 25 additions & 0 deletions docs/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,28 @@ query foo {
So the above query would return all documents that have a question named "foo"
with the value "bar", but exclude all documents from that list where another
question "baz" has the value "hello".

We also intend to syntactically separate ordering from filtering, which
"traditionally" was the same: In REST APIs, you would have query strings
that could configure both filtering and sorting, like this:
`?foo=bar&ordering=blah`. GrahpQL doesn't really provide independent syntax for
this either: `allDocuments(hasAnswer:{question:"foo",value:"bar"},orderBy=MODIFIED_AT_ASC)`

Our future interface will separate those two concerns in a clean syntactic
manner:

```graphql
query foo {
allDocuments(
filter: [
{hasAnswer: {question: "foo", value: "bar"}},
...
],
ordering: [
...
]
) {
...
}
}
```

0 comments on commit cbb8ac9

Please sign in to comment.