Skip to content

Commit

Permalink
[@searchBy] Condition type split into Root (with extra operator…
Browse files Browse the repository at this point in the history
…s) and `Condition` (without).
  • Loading branch information
LastDragon-ru committed Feb 8, 2024
1 parent 54ddd26 commit da5efb7
Show file tree
Hide file tree
Showing 25 changed files with 580 additions and 541 deletions.
8 changes: 4 additions & 4 deletions packages/graphql/src/SearchBy/Directives/DirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function testDirective(
)
->graphQL(
<<<'GRAPHQL'
query test($input: SearchByConditionTestObject) {
query test($input: SearchByRootTestObject) {
test(input: $input) {
id
}
Expand Down Expand Up @@ -233,8 +233,8 @@ public function testHandleBuilder(
);

$type = match (true) {
$builder instanceof QueryBuilder => 'SearchByQueryConditionTest',
default => 'SearchByConditionTest',
$builder instanceof QueryBuilder => 'SearchByQueryRootTest',
default => 'SearchByRootTest',
};
$result = $this->graphQL(
<<<GRAPHQL
Expand Down Expand Up @@ -312,7 +312,7 @@ static function (MockInterface $mock) use ($resolver): void {

$result = $this->graphQL(
<<<'GRAPHQL'
query test($query: SearchByScoutConditionTest) {
query test($query: SearchByScoutRootTest) {
test(search: "*", input: $query)
}
GRAPHQL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on
"""
Available conditions for `type A` (only one property allowed at a time).
"""
input SearchByConditionA {
input SearchByRootA {
"""
Field condition.
"""
Expand All @@ -34,7 +34,7 @@ input SearchByConditionA {
"""
Available conditions for `interface B` (only one property allowed at a time).
"""
input SearchByConditionB {
input SearchByRootB {
"""
Field condition.
"""
Expand Down Expand Up @@ -72,13 +72,13 @@ type A {

type Query {
a(
where: SearchByConditionA
where: SearchByRootA
@searchBy
): A!
@all

b(
where: SearchByConditionB
where: SearchByRootB
@searchBy
): B!
@all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,55 @@ input SearchByComplexCustomInt {
custom: Int
}

"""
Conditions for the relationship (`has()`/`doesntHave()`) for `input Child`.
See also:
* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence
* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence
"""
input SearchByRelationshipRelationChild {
"""
Count conditions.
"""
count: SearchByScalarInt

"""
Alias for `count: {greaterThanOrEqual: 1}`. Will be ignored if `count` used.
"""
exists: Boolean

"""
Alias for `count: {lessThan: 1}`. Will be ignored if `count` used.
"""
notExists: Boolean! = false

"""
Additional conditions.
"""
where: SearchByRootChild
}

"""
Available conditions for `input Child` (only one property allowed at a time).
"""
input SearchByConditionChild {
input SearchByRootChild {
"""
All of the conditions must be true.
"""
allOf: [SearchByConditionChild!]
allOf: [SearchByRootChild!]
@searchByOperatorAllOf

"""
Any of the conditions must be true.
"""
anyOf: [SearchByConditionChild!]
anyOf: [SearchByRootChild!]
@searchByOperatorAnyOf

"""
Not.
"""
not: SearchByConditionChild
not: SearchByRootChild
@searchByOperatorNot

"""
Expand All @@ -240,17 +269,17 @@ input SearchByConditionChild {
"""
Available conditions for `input Properties` (only one property allowed at a time).
"""
input SearchByConditionProperties {
input SearchByRootProperties {
"""
All of the conditions must be true.
"""
allOf: [SearchByConditionProperties!]
allOf: [SearchByRootProperties!]
@searchByOperatorAllOf

"""
Any of the conditions must be true.
"""
anyOf: [SearchByConditionProperties!]
anyOf: [SearchByRootProperties!]
@searchByOperatorAnyOf

"""
Expand All @@ -276,39 +305,10 @@ input SearchByConditionProperties {
"""
Not.
"""
not: SearchByConditionProperties
not: SearchByRootProperties
@searchByOperatorNot
}

"""
Conditions for the relationship (`has()`/`doesntHave()`) for `input Child`.
See also:
* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence
* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence
"""
input SearchByRelationshipRelationChild {
"""
Count conditions.
"""
count: SearchByScalarInt

"""
Alias for `count: {greaterThanOrEqual: 1}`. Will be ignored if `count` used.
"""
exists: Boolean

"""
Alias for `count: {lessThan: 1}`. Will be ignored if `count` used.
"""
notExists: Boolean! = false

"""
Additional conditions.
"""
where: SearchByConditionChild
}

"""
Available operators for `scalar Int` (only one operator allowed at a time).
"""
Expand Down Expand Up @@ -500,7 +500,7 @@ input SearchByTypeRangeInt {

type Query {
test(
where: SearchByConditionProperties
where: SearchByRootProperties
@searchBy
): ID!
@all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,49 @@ input Comment {
@belongsTo
}

"""
Conditions for the relationship (`has()`/`doesntHave()`) for `input UsersQuery`.
See also:
* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence
* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence
"""
input SearchByRelationshipRelationUsersQuery {
"""
Count conditions.
"""
count: SearchByScalarInt

"""
Alias for `count: {greaterThanOrEqual: 1}`. Will be ignored if `count` used.
"""
exists: Boolean

"""
Alias for `count: {lessThan: 1}`. Will be ignored if `count` used.
"""
notExists: Boolean! = false

"""
Additional conditions.
"""
where: SearchByRootUsersQuery
}

"""
Available conditions for `input CommentsQuery` (only one property allowed at a time).
"""
input SearchByConditionCommentsQuery {
input SearchByRootCommentsQuery {
"""
All of the conditions must be true.
"""
allOf: [SearchByConditionCommentsQuery!]
allOf: [SearchByRootCommentsQuery!]
@searchByOperatorAllOf

"""
Any of the conditions must be true.
"""
anyOf: [SearchByConditionCommentsQuery!]
anyOf: [SearchByRootCommentsQuery!]
@searchByOperatorAnyOf

"""
Expand All @@ -228,7 +257,7 @@ input SearchByConditionCommentsQuery {
"""
Not.
"""
not: SearchByConditionCommentsQuery
not: SearchByRootCommentsQuery
@searchByOperatorNot

"""
Expand All @@ -247,17 +276,17 @@ input SearchByConditionCommentsQuery {
"""
Available conditions for `type User` (only one property allowed at a time).
"""
input SearchByConditionUser {
input SearchByRootUser {
"""
All of the conditions must be true.
"""
allOf: [SearchByConditionUser!]
allOf: [SearchByRootUser!]
@searchByOperatorAllOf

"""
Any of the conditions must be true.
"""
anyOf: [SearchByConditionUser!]
anyOf: [SearchByRootUser!]
@searchByOperatorAnyOf

"""
Expand All @@ -275,24 +304,24 @@ input SearchByConditionUser {
"""
Not.
"""
not: SearchByConditionUser
not: SearchByRootUser
@searchByOperatorNot
}

"""
Available conditions for `input UsersQuery` (only one property allowed at a time).
"""
input SearchByConditionUsersQuery {
input SearchByRootUsersQuery {
"""
All of the conditions must be true.
"""
allOf: [SearchByConditionUsersQuery!]
allOf: [SearchByRootUsersQuery!]
@searchByOperatorAllOf

"""
Any of the conditions must be true.
"""
anyOf: [SearchByConditionUsersQuery!]
anyOf: [SearchByRootUsersQuery!]
@searchByOperatorAnyOf

"""
Expand All @@ -310,39 +339,10 @@ input SearchByConditionUsersQuery {
"""
Not.
"""
not: SearchByConditionUsersQuery
not: SearchByRootUsersQuery
@searchByOperatorNot
}

"""
Conditions for the relationship (`has()`/`doesntHave()`) for `input UsersQuery`.
See also:
* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence
* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence
"""
input SearchByRelationshipRelationUsersQuery {
"""
Count conditions.
"""
count: SearchByScalarInt

"""
Alias for `count: {greaterThanOrEqual: 1}`. Will be ignored if `count` used.
"""
exists: Boolean

"""
Alias for `count: {lessThan: 1}`. Will be ignored if `count` used.
"""
notExists: Boolean! = false

"""
Additional conditions.
"""
where: SearchByConditionUsersQuery
}

"""
Available operators for `scalar Date` (only one operator allowed at a time).
"""
Expand Down Expand Up @@ -584,13 +584,13 @@ scalar Date

type Query {
comments(
where: SearchByConditionCommentsQuery
where: SearchByRootCommentsQuery
@searchBy
): [Comment!]!
@all

users(
where: SearchByConditionUser
where: SearchByRootUser
@searchBy
): [User!]!
@all
Expand Down
Loading

0 comments on commit da5efb7

Please sign in to comment.