-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API Generator: Add
search
argument to OneToManyFilter
and `ManyTo…
…ManyFilter` (#2238) This PR adds search filter to OneToMany and ManyToMany relations, that can be used where a select is impossible to use because of too many related entities. Doing a poor-mans fulltext search doesn't have this problem (also has poor performance on the server side though) The old method (how search was implemented for list queries) didn't apply here well, so I decided do go a different approach: Instead of generating code (the service) that lists all fields to query, we find those fields at runtime now. We are using (1) MikroORM metadata and (2) our CrudField resolver, the search boolean. Just as before. And with this new approach it is possible to do that also for related entities that makes implementing the search possible. --------- Co-authored-by: Johannes Obermair <[email protected]>
- Loading branch information
1 parent
d1b7f5f
commit 4485d15
Showing
29 changed files
with
192 additions
and
376 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@comet/cms-api": major | ||
--- | ||
|
||
filtersToMikroOrmQuery: Move second argument (`applyFilter` callback) into an options object |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@comet/cms-api": minor | ||
--- | ||
|
||
API Generator: Add `search` argument to `OneToManyFilter` and `ManyToManyFilter` | ||
|
||
Performs a search like the `search` argument in the list query. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@comet/cms-api": major | ||
--- | ||
|
||
API Generator: Remove generated service | ||
|
||
The `Service#getFindCondition` method is replaced with the new `gqlArgsToMikroOrmQuery` function, which detects an entity's searchable fields from its metadata. | ||
Consequently, the generated service isn't needed anymore and will therefore no longer be generated. | ||
Remove the service from the module after re-running the API Generator. |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
25 changes: 0 additions & 25 deletions
25
demo/api/src/products/generated/manufacturer-countries.service.ts
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
demo/api/src/products/generated/product-categories.service.ts
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.