From da5efb7d4a559377087b3c5ce19ab87be1ae4fbd Mon Sep 17 00:00:00 2001 From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:09:22 +0400 Subject: [PATCH] [`@searchBy`] `Condition` type split into `Root` (with extra operators) and `Condition` (without). --- .../src/SearchBy/Directives/DirectiveTest.php | 8 +- .../AllowedDirectives.expected.graphql | 8 +- .../CustomComplexOperator.expected.graphql | 76 ++++---- .../DirectiveTest/Example.expected.graphql | 86 ++++----- .../DirectiveTest/Explicit.expected.graphql | 136 +++++++-------- .../DirectiveTest/Ignored.expected.graphql | 8 +- .../DirectiveTest/Implicit.expected.graphql | 150 ++++++++-------- .../InterfaceUpdate.expected.graphql | 16 +- .../DirectiveTest/Query.expected.graphql | 20 +-- .../ScalarOperators.expected.graphql | 52 +++--- .../DirectiveTest/Scout.expected.graphql | 140 +++++++-------- .../Scout.expected.v10.3.0.graphql | 164 +++++++++--------- .../TypeRegistry.expected.graphql | 150 ++++++++-------- .../graphql/src/SearchBy/Operators/Child.php | 4 +- .../Operators/Complex/RelationshipType.php | 4 +- .../src/SearchBy/Operators/Logical/AllOf.php | 6 +- .../src/SearchBy/Operators/Logical/AnyOf.php | 6 +- .../SearchBy/Operators/Logical/Logical.php | 4 +- .../graphql/src/SearchBy/Operators/Root.php | 4 +- .../SearchBy/Types/Condition/Condition.php | 24 +++ .../src/SearchBy/Types/Condition/Root.php | 7 + .../{Condition.php => Condition/Type.php} | 10 +- .../src/Stream/Directives/DirectiveTest.php | 4 +- .../DirectiveTest~schema-expected.graphql | 26 +-- .../DirectiveTest~scout-expected.graphql | 8 +- 25 files changed, 580 insertions(+), 541 deletions(-) create mode 100644 packages/graphql/src/SearchBy/Types/Condition/Condition.php create mode 100644 packages/graphql/src/SearchBy/Types/Condition/Root.php rename packages/graphql/src/SearchBy/Types/{Condition.php => Condition/Type.php} (89%) diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest.php b/packages/graphql/src/SearchBy/Directives/DirectiveTest.php index e79e6b704..2eb16af60 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest.php +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest.php @@ -184,7 +184,7 @@ public function testDirective( ) ->graphQL( <<<'GRAPHQL' - query test($input: SearchByConditionTestObject) { + query test($input: SearchByRootTestObject) { test(input: $input) { id } @@ -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( <<<'GRAPHQL' - query test($query: SearchByScoutConditionTest) { + query test($query: SearchByScoutRootTest) { test(search: "*", input: $query) } GRAPHQL, diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/AllowedDirectives.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/AllowedDirectives.expected.graphql index df7afbb52..ca922e2c1 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/AllowedDirectives.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/AllowedDirectives.expected.graphql @@ -20,7 +20,7 @@ on """ Available conditions for `type A` (only one property allowed at a time). """ -input SearchByConditionA { +input SearchByRootA { """ Field condition. """ @@ -34,7 +34,7 @@ input SearchByConditionA { """ Available conditions for `interface B` (only one property allowed at a time). """ -input SearchByConditionB { +input SearchByRootB { """ Field condition. """ @@ -72,13 +72,13 @@ type A { type Query { a( - where: SearchByConditionA + where: SearchByRootA @searchBy ): A! @all b( - where: SearchByConditionB + where: SearchByRootB @searchBy ): B! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/CustomComplexOperator.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/CustomComplexOperator.expected.graphql index ad1c3e957..7d08d95f2 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/CustomComplexOperator.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/CustomComplexOperator.expected.graphql @@ -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 """ @@ -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 """ @@ -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). """ @@ -500,7 +500,7 @@ input SearchByTypeRangeInt { type Query { test( - where: SearchByConditionProperties + where: SearchByRootProperties @searchBy ): ID! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Example.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Example.expected.graphql index 47b872c7d..aad9d7942 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Example.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Example.expected.graphql @@ -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 """ @@ -228,7 +257,7 @@ input SearchByConditionCommentsQuery { """ Not. """ - not: SearchByConditionCommentsQuery + not: SearchByRootCommentsQuery @searchByOperatorNot """ @@ -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 """ @@ -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 """ @@ -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). """ @@ -584,13 +584,13 @@ scalar Date type Query { comments( - where: SearchByConditionCommentsQuery + where: SearchByRootCommentsQuery @searchBy ): [Comment!]! @all users( - where: SearchByConditionUser + where: SearchByRootUser @searchBy ): [User!]! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Explicit.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Explicit.expected.graphql index 4904689f0..e3a3372f6 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Explicit.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Explicit.expected.graphql @@ -217,20 +217,78 @@ input B { parent: A! } +""" +Conditions for the relationship (`has()`/`doesntHave()`) for `input A`. + +See also: +* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence +* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence +""" +input SearchByRelationshipRelationA { + """ + 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: SearchByRootA +} + +""" +Conditions for the relationship (`has()`/`doesntHave()`) for `input B`. + +See also: +* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence +* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence +""" +input SearchByRelationshipRelationB { + """ + 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: SearchByRootB +} + """ Available conditions for `input A` (only one property allowed at a time). """ -input SearchByConditionA { +input SearchByRootA { """ All of the conditions must be true. """ - allOf: [SearchByConditionA!] + allOf: [SearchByRootA!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByConditionA!] + anyOf: [SearchByRootA!] @searchByOperatorAnyOf """ @@ -260,24 +318,24 @@ input SearchByConditionA { """ Not. """ - not: SearchByConditionA + not: SearchByRootA @searchByOperatorNot } """ Available conditions for `input B` (only one property allowed at a time). """ -input SearchByConditionB { +input SearchByRootB { """ All of the conditions must be true. """ - allOf: [SearchByConditionB!] + allOf: [SearchByRootB!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByConditionB!] + anyOf: [SearchByRootB!] @searchByOperatorAnyOf """ @@ -295,7 +353,7 @@ input SearchByConditionB { """ Not. """ - not: SearchByConditionB + not: SearchByRootB @searchByOperatorNot """ @@ -305,64 +363,6 @@ input SearchByConditionB { @searchByOperatorRelationship } -""" -Conditions for the relationship (`has()`/`doesntHave()`) for `input A`. - -See also: -* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence -* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence -""" -input SearchByRelationshipRelationA { - """ - 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: SearchByConditionA -} - -""" -Conditions for the relationship (`has()`/`doesntHave()`) for `input B`. - -See also: -* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence -* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence -""" -input SearchByRelationshipRelationB { - """ - 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: SearchByConditionB -} - """ Available operators for `scalar ID` (only one operator allowed at a time). """ @@ -730,13 +730,13 @@ type PaginatorInfo { type Query { a( - where: SearchByConditionA + where: SearchByRootA @searchBy ): ID! @all b( - where: SearchByConditionA + where: SearchByRootA @searchBy """ diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Ignored.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Ignored.expected.graphql index 4fbfe01bc..2db726b03 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Ignored.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Ignored.expected.graphql @@ -69,7 +69,7 @@ input IgnoredType { """ Available conditions for `input A` (only one property allowed at a time). """ -input SearchByConditionA { +input SearchByRootA { """ Not ignored """ @@ -86,7 +86,7 @@ input SearchByConditionA { """ Available conditions for `interface B` (only one property allowed at a time). """ -input SearchByConditionB { +input SearchByRootB { """ Field condition. """ @@ -170,13 +170,13 @@ type ObjectB { type Query { a( - where: SearchByConditionA + where: SearchByRootA @searchBy ): A! @all b( - where: SearchByConditionB + where: SearchByRootB @searchBy ): B! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Implicit.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Implicit.expected.graphql index d6648dde8..48d6dfb20 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Implicit.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Implicit.expected.graphql @@ -263,20 +263,78 @@ enum SearchByTypeFlag { ) } +""" +Conditions for the relationship (`has()`/`doesntHave()`) for `type A`. + +See also: +* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence +* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence +""" +input SearchByRelationshipRelationA { + """ + 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: SearchByRootA +} + +""" +Conditions for the relationship (`has()`/`doesntHave()`) for `type B`. + +See also: +* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence +* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence +""" +input SearchByRelationshipRelationB { + """ + 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: SearchByRootB +} + """ Available conditions for `type A` (only one property allowed at a time). """ -input SearchByConditionA { +input SearchByRootA { """ All of the conditions must be true. """ - allOf: [SearchByConditionA!] + allOf: [SearchByRootA!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByConditionA!] + anyOf: [SearchByRootA!] @searchByOperatorAnyOf """ @@ -294,7 +352,7 @@ input SearchByConditionA { """ Not. """ - not: SearchByConditionA + not: SearchByRootA @searchByOperatorNot """ @@ -367,17 +425,17 @@ input SearchByConditionA { """ Available conditions for `type B` (only one property allowed at a time). """ -input SearchByConditionB { +input SearchByRootB { """ All of the conditions must be true. """ - allOf: [SearchByConditionB!] + allOf: [SearchByRootB!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByConditionB!] + anyOf: [SearchByRootB!] @searchByOperatorAnyOf """ @@ -395,7 +453,7 @@ input SearchByConditionB { """ Not. """ - not: SearchByConditionB + not: SearchByRootB @searchByOperatorNot """ @@ -408,17 +466,17 @@ input SearchByConditionB { """ Available conditions for `interface C` (only one property allowed at a time). """ -input SearchByConditionC { +input SearchByRootC { """ All of the conditions must be true. """ - allOf: [SearchByConditionC!] + allOf: [SearchByRootC!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByConditionC!] + anyOf: [SearchByRootC!] @searchByOperatorAnyOf """ @@ -436,7 +494,7 @@ input SearchByConditionC { """ Not. """ - not: SearchByConditionC + not: SearchByRootC @searchByOperatorNot """ @@ -506,64 +564,6 @@ input SearchByConditionC { ) } -""" -Conditions for the relationship (`has()`/`doesntHave()`) for `type A`. - -See also: -* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence -* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence -""" -input SearchByRelationshipRelationA { - """ - 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: SearchByConditionA -} - -""" -Conditions for the relationship (`has()`/`doesntHave()`) for `type B`. - -See also: -* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence -* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence -""" -input SearchByRelationshipRelationB { - """ - 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: SearchByConditionB -} - """ Available operators for `scalar ID` (only one operator allowed at a time). """ @@ -981,7 +981,7 @@ interface C { ) stream( - where: SearchByConditionA + where: SearchByRootA @searchBy """ @@ -1123,7 +1123,7 @@ type A { ) stream( - where: SearchByConditionA + where: SearchByRootA @searchBy """ @@ -1273,13 +1273,13 @@ type PaginatorInfo { type Query { a( - where: SearchByConditionA + where: SearchByRootA @searchBy ): [A!]! @all b( - where: SearchByConditionA + where: SearchByRootA @searchBy """ @@ -1297,7 +1297,7 @@ type Query { ) c( - where: SearchByConditionC + where: SearchByRootC @searchBy ): [C!]! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/InterfaceUpdate.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/InterfaceUpdate.expected.graphql index 82f6ab63d..5bcf235a1 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/InterfaceUpdate.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/InterfaceUpdate.expected.graphql @@ -24,7 +24,7 @@ input A { """ Available conditions for `input A` (only one property allowed at a time). """ -input SearchByConditionA { +input SearchByRootA { """ Field condition. """ @@ -35,7 +35,7 @@ input SearchByConditionA { """ Available conditions for `type B` (only one property allowed at a time). """ -input SearchByConditionB { +input SearchByRootB { """ Field condition. """ @@ -60,23 +60,23 @@ implements & QueryInterfaceB { a( - where: SearchByConditionA + where: SearchByRootA ): A! b( - where: SearchByConditionB + where: SearchByRootB ): B! } interface QueryInterfaceA { a( - where: SearchByConditionA + where: SearchByRootA ): A! } interface QueryInterfaceB { b( - where: SearchByConditionB + where: SearchByRootB ): B! } @@ -89,13 +89,13 @@ implements & QueryInterface { a( - where: SearchByConditionA + where: SearchByRootA @searchBy ): A! @all b( - where: SearchByConditionB + where: SearchByRootB @searchBy ): B! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Query.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Query.expected.graphql index 478a9c238..5764eaf35 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Query.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Query.expected.graphql @@ -125,17 +125,17 @@ enum SearchByTypeFlag { """ Available conditions for `input InputA` (only one property allowed at a time). """ -input SearchByQueryConditionInputA { +input SearchByQueryRootInputA { """ All of the conditions must be true. """ - allOf: [SearchByQueryConditionInputA!] + allOf: [SearchByQueryRootInputA!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByQueryConditionInputA!] + anyOf: [SearchByQueryRootInputA!] @searchByOperatorAnyOf """ @@ -153,24 +153,24 @@ input SearchByQueryConditionInputA { """ Not. """ - not: SearchByQueryConditionInputA + not: SearchByQueryRootInputA @searchByOperatorNot } """ Available conditions for `input TypeB` (only one property allowed at a time). """ -input SearchByQueryConditionTypeB { +input SearchByQueryRootTypeB { """ All of the conditions must be true. """ - allOf: [SearchByQueryConditionTypeB!] + allOf: [SearchByQueryRootTypeB!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByQueryConditionTypeB!] + anyOf: [SearchByQueryRootTypeB!] @searchByOperatorAnyOf """ @@ -188,7 +188,7 @@ input SearchByQueryConditionTypeB { """ Not. """ - not: SearchByQueryConditionTypeB + not: SearchByQueryRootTypeB @searchByOperatorNot } @@ -401,7 +401,7 @@ input TypeB { type Query { a( - where: SearchByQueryConditionInputA + where: SearchByQueryRootInputA @searchBy ): ID! @all( @@ -409,7 +409,7 @@ type Query { ) b( - where: SearchByQueryConditionTypeB + where: SearchByQueryRootTypeB @searchBy ): [TypeB!]! @all( diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.expected.graphql index b3e664bde..1a7b65623 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.expected.graphql @@ -84,10 +84,33 @@ enum SearchByTypeFlag { ) } +""" +Available operators for `enum EnumA` (only one operator allowed at a time). +""" +input SearchByEnumEnumAOrNull { + """ + Within a set of values. + """ + in: [EnumA!] + @searchByOperatorIn + + """ + Is NOT NULL? + """ + isNotNull: SearchByTypeFlag + @searchByOperatorIsNotNull + + """ + Is NULL? + """ + isNull: SearchByTypeFlag + @searchByOperatorIsNull +} + """ Available conditions for `input A` (only one property allowed at a time). """ -input SearchByConditionA { +input SearchByRootA { """ Field condition. """ @@ -97,7 +120,7 @@ input SearchByConditionA { """ All of the conditions must be true. """ - allOf: [SearchByConditionA!] + allOf: [SearchByRootA!] @searchByOperatorAllOf """ @@ -113,29 +136,6 @@ input SearchByConditionA { @searchByOperatorCondition } -""" -Available operators for `enum EnumA` (only one operator allowed at a time). -""" -input SearchByEnumEnumAOrNull { - """ - Within a set of values. - """ - in: [EnumA!] - @searchByOperatorIn - - """ - Is NOT NULL? - """ - isNotNull: SearchByTypeFlag - @searchByOperatorIsNotNull - - """ - Is NULL? - """ - isNull: SearchByTypeFlag - @searchByOperatorIsNull -} - """ Available operators for `scalar Date` (only one operator allowed at a time). """ @@ -211,7 +211,7 @@ scalar Mixed type Query { test( - where: SearchByConditionA + where: SearchByRootA @searchBy ): ID! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.graphql index e36ded74d..6f8554847 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.graphql @@ -80,14 +80,48 @@ enum EnumIgnored One } +""" +Available operators for `enum EnumA` (only one operator allowed at a time). +""" +input SearchByScoutEnumEnumA { + """ + Equal (`=`). + """ + equal: EnumA + @searchByOperatorEqual + + """ + Within a set of values. + """ + in: [EnumA!] + @searchByOperatorIn +} + +""" +Available operators for `enum EnumA` (only one operator allowed at a time). +""" +input SearchByScoutEnumEnumAOrNull { + """ + Equal (`=`). + """ + equal: EnumA + @searchByOperatorEqual + + """ + Within a set of values. + """ + in: [EnumA!] + @searchByOperatorIn +} + """ Available conditions for `input InputA` (only one property allowed at a time). """ -input SearchByScoutConditionInputA { +input SearchByScoutRootInputA { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionInputA!] + allOf: [SearchByScoutRootInputA!] @searchByOperatorAllOf """ @@ -192,13 +226,13 @@ input SearchByScoutConditionInputA { """ Field condition. """ - nested: SearchByScoutConditionNestedA + nested: SearchByScoutRootNestedA @searchByOperatorChild """ Field condition. """ - nestedNotNull: SearchByScoutConditionNestedA + nestedNotNull: SearchByScoutRootNestedA @searchByOperatorChild """ @@ -223,11 +257,11 @@ input SearchByScoutConditionInputA { """ Available conditions for `input InputB` (only one property allowed at a time). """ -input SearchByScoutConditionInputB { +input SearchByScoutRootInputB { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionInputB!] + allOf: [SearchByScoutRootInputB!] @searchByOperatorAllOf """ @@ -240,17 +274,17 @@ input SearchByScoutConditionInputB { """ Available conditions for `input NestedA` (only one property allowed at a time). """ -input SearchByScoutConditionNestedA { +input SearchByScoutRootNestedA { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionNestedA!] + allOf: [SearchByScoutRootNestedA!] @searchByOperatorAllOf """ Field condition. """ - nested: SearchByScoutConditionNestedA + nested: SearchByScoutRootNestedA @searchByOperatorChild """ @@ -263,45 +297,45 @@ input SearchByScoutConditionNestedA { """ Available conditions for `input NestedB` (only one property allowed at a time). """ -input SearchByScoutConditionNestedB { +input SearchByScoutRootNestedB { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionNestedB!] + allOf: [SearchByScoutRootNestedB!] @searchByOperatorAllOf """ Field condition. """ - nested: SearchByScoutConditionNestedC + nested: SearchByScoutRootNestedC @searchByOperatorChild } """ Available conditions for `input NestedC` (only one property allowed at a time). """ -input SearchByScoutConditionNestedC { +input SearchByScoutRootNestedC { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionNestedC!] + allOf: [SearchByScoutRootNestedC!] @searchByOperatorAllOf """ Field condition. """ - nested: SearchByScoutConditionNestedB + nested: SearchByScoutRootNestedB @searchByOperatorChild } """ Available conditions for `type Object` (only one property allowed at a time). """ -input SearchByScoutConditionObject { +input SearchByScoutRootObject { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionObject!] + allOf: [SearchByScoutRootObject!] @searchByOperatorAllOf """ @@ -406,13 +440,13 @@ input SearchByScoutConditionObject { """ Field condition. """ - nested: SearchByScoutConditionObjectNested + nested: SearchByScoutRootObjectNested @searchByOperatorChild """ Field condition. """ - nestedNotNull: SearchByScoutConditionObjectNested + nestedNotNull: SearchByScoutRootObjectNested @searchByOperatorChild """ @@ -431,11 +465,11 @@ input SearchByScoutConditionObject { """ Available conditions for `interface ObjectInterface` (only one property allowed at a time). """ -input SearchByScoutConditionObjectInterface { +input SearchByScoutRootObjectInterface { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionObjectInterface!] + allOf: [SearchByScoutRootObjectInterface!] @searchByOperatorAllOf """ @@ -540,13 +574,13 @@ input SearchByScoutConditionObjectInterface { """ Field condition. """ - nested: SearchByScoutConditionObjectNested + nested: SearchByScoutRootObjectNested @searchByOperatorChild """ Field condition. """ - nestedNotNull: SearchByScoutConditionObjectNested + nestedNotNull: SearchByScoutRootObjectNested @searchByOperatorChild """ @@ -565,11 +599,11 @@ input SearchByScoutConditionObjectInterface { """ Available conditions for `type ObjectNested` (only one property allowed at a time). """ -input SearchByScoutConditionObjectNested { +input SearchByScoutRootObjectNested { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionObjectNested!] + allOf: [SearchByScoutRootObjectNested!] @searchByOperatorAllOf """ @@ -579,40 +613,6 @@ input SearchByScoutConditionObjectNested { @searchByOperatorCondition } -""" -Available operators for `enum EnumA` (only one operator allowed at a time). -""" -input SearchByScoutEnumEnumA { - """ - Equal (`=`). - """ - equal: EnumA - @searchByOperatorEqual - - """ - Within a set of values. - """ - in: [EnumA!] - @searchByOperatorIn -} - -""" -Available operators for `enum EnumA` (only one operator allowed at a time). -""" -input SearchByScoutEnumEnumAOrNull { - """ - Equal (`=`). - """ - equal: EnumA - @searchByOperatorEqual - - """ - Within a set of values. - """ - in: [EnumA!] - @searchByOperatorIn -} - """ Available operators for `scalar Boolean` (only one operator allowed at a time). """ @@ -810,19 +810,19 @@ implements & F { a( - where: SearchByScoutConditionInputA + where: SearchByScoutRootInputA ): ID! } interface B { b( - where: SearchByScoutConditionNestedA + where: SearchByScoutRootNestedA ): ID! } interface C { c( - where: SearchByScoutConditionInputB + where: SearchByScoutRootInputB ): ID! } @@ -831,7 +831,7 @@ interface F { search: String @search - where: SearchByScoutConditionObject + where: SearchByScoutRootObject @searchBy ): Object! @all @@ -1011,7 +1011,7 @@ implements search: String @search - where: SearchByScoutConditionInputA + where: SearchByScoutRootInputA @searchBy ): ID! @all @@ -1020,7 +1020,7 @@ implements search: String @search - where: SearchByScoutConditionNestedA + where: SearchByScoutRootNestedA @searchBy ): ID! @all @@ -1029,7 +1029,7 @@ implements search: String @search - where: SearchByScoutConditionInputB + where: SearchByScoutRootInputB @searchBy ): ID! @all @@ -1038,7 +1038,7 @@ implements search: String @search - where: SearchByScoutConditionNestedB + where: SearchByScoutRootNestedB @searchBy ): ID! @all @@ -1047,7 +1047,7 @@ implements search: String @search - where: SearchByScoutConditionInputA + where: SearchByScoutRootInputA @searchBy ): ID! @all @@ -1056,7 +1056,7 @@ implements search: String @search - where: SearchByScoutConditionObject + where: SearchByScoutRootObject @searchBy ): Object! @all @@ -1065,7 +1065,7 @@ implements search: String @search - where: SearchByScoutConditionObjectInterface + where: SearchByScoutRootObjectInterface @searchBy ): ObjectInterface! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.v10.3.0.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.v10.3.0.graphql index ac8ca7a82..0a23a7ff0 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.v10.3.0.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/Scout.expected.v10.3.0.graphql @@ -86,14 +86,60 @@ enum EnumIgnored One } +""" +Available operators for `enum EnumA` (only one operator allowed at a time). +""" +input SearchByScoutEnumEnumA { + """ + Equal (`=`). + """ + equal: EnumA + @searchByOperatorEqual + + """ + Within a set of values. + """ + in: [EnumA!] + @searchByOperatorIn + + """ + Outside a set of values. + """ + notIn: [EnumA!] + @searchByOperatorNotIn +} + +""" +Available operators for `enum EnumA` (only one operator allowed at a time). +""" +input SearchByScoutEnumEnumAOrNull { + """ + Equal (`=`). + """ + equal: EnumA + @searchByOperatorEqual + + """ + Within a set of values. + """ + in: [EnumA!] + @searchByOperatorIn + + """ + Outside a set of values. + """ + notIn: [EnumA!] + @searchByOperatorNotIn +} + """ Available conditions for `input InputA` (only one property allowed at a time). """ -input SearchByScoutConditionInputA { +input SearchByScoutRootInputA { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionInputA!] + allOf: [SearchByScoutRootInputA!] @searchByOperatorAllOf """ @@ -198,13 +244,13 @@ input SearchByScoutConditionInputA { """ Field condition. """ - nested: SearchByScoutConditionNestedA + nested: SearchByScoutRootNestedA @searchByOperatorChild """ Field condition. """ - nestedNotNull: SearchByScoutConditionNestedA + nestedNotNull: SearchByScoutRootNestedA @searchByOperatorChild """ @@ -229,11 +275,11 @@ input SearchByScoutConditionInputA { """ Available conditions for `input InputB` (only one property allowed at a time). """ -input SearchByScoutConditionInputB { +input SearchByScoutRootInputB { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionInputB!] + allOf: [SearchByScoutRootInputB!] @searchByOperatorAllOf """ @@ -246,17 +292,17 @@ input SearchByScoutConditionInputB { """ Available conditions for `input NestedA` (only one property allowed at a time). """ -input SearchByScoutConditionNestedA { +input SearchByScoutRootNestedA { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionNestedA!] + allOf: [SearchByScoutRootNestedA!] @searchByOperatorAllOf """ Field condition. """ - nested: SearchByScoutConditionNestedA + nested: SearchByScoutRootNestedA @searchByOperatorChild """ @@ -269,45 +315,45 @@ input SearchByScoutConditionNestedA { """ Available conditions for `input NestedB` (only one property allowed at a time). """ -input SearchByScoutConditionNestedB { +input SearchByScoutRootNestedB { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionNestedB!] + allOf: [SearchByScoutRootNestedB!] @searchByOperatorAllOf """ Field condition. """ - nested: SearchByScoutConditionNestedC + nested: SearchByScoutRootNestedC @searchByOperatorChild } """ Available conditions for `input NestedC` (only one property allowed at a time). """ -input SearchByScoutConditionNestedC { +input SearchByScoutRootNestedC { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionNestedC!] + allOf: [SearchByScoutRootNestedC!] @searchByOperatorAllOf """ Field condition. """ - nested: SearchByScoutConditionNestedB + nested: SearchByScoutRootNestedB @searchByOperatorChild } """ Available conditions for `type Object` (only one property allowed at a time). """ -input SearchByScoutConditionObject { +input SearchByScoutRootObject { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionObject!] + allOf: [SearchByScoutRootObject!] @searchByOperatorAllOf """ @@ -412,13 +458,13 @@ input SearchByScoutConditionObject { """ Field condition. """ - nested: SearchByScoutConditionObjectNested + nested: SearchByScoutRootObjectNested @searchByOperatorChild """ Field condition. """ - nestedNotNull: SearchByScoutConditionObjectNested + nestedNotNull: SearchByScoutRootObjectNested @searchByOperatorChild """ @@ -437,11 +483,11 @@ input SearchByScoutConditionObject { """ Available conditions for `interface ObjectInterface` (only one property allowed at a time). """ -input SearchByScoutConditionObjectInterface { +input SearchByScoutRootObjectInterface { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionObjectInterface!] + allOf: [SearchByScoutRootObjectInterface!] @searchByOperatorAllOf """ @@ -546,13 +592,13 @@ input SearchByScoutConditionObjectInterface { """ Field condition. """ - nested: SearchByScoutConditionObjectNested + nested: SearchByScoutRootObjectNested @searchByOperatorChild """ Field condition. """ - nestedNotNull: SearchByScoutConditionObjectNested + nestedNotNull: SearchByScoutRootObjectNested @searchByOperatorChild """ @@ -571,11 +617,11 @@ input SearchByScoutConditionObjectInterface { """ Available conditions for `type ObjectNested` (only one property allowed at a time). """ -input SearchByScoutConditionObjectNested { +input SearchByScoutRootObjectNested { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionObjectNested!] + allOf: [SearchByScoutRootObjectNested!] @searchByOperatorAllOf """ @@ -585,52 +631,6 @@ input SearchByScoutConditionObjectNested { @searchByOperatorCondition } -""" -Available operators for `enum EnumA` (only one operator allowed at a time). -""" -input SearchByScoutEnumEnumA { - """ - Equal (`=`). - """ - equal: EnumA - @searchByOperatorEqual - - """ - Within a set of values. - """ - in: [EnumA!] - @searchByOperatorIn - - """ - Outside a set of values. - """ - notIn: [EnumA!] - @searchByOperatorNotIn -} - -""" -Available operators for `enum EnumA` (only one operator allowed at a time). -""" -input SearchByScoutEnumEnumAOrNull { - """ - Equal (`=`). - """ - equal: EnumA - @searchByOperatorEqual - - """ - Within a set of values. - """ - in: [EnumA!] - @searchByOperatorIn - - """ - Outside a set of values. - """ - notIn: [EnumA!] - @searchByOperatorNotIn -} - """ Available operators for `scalar Boolean` (only one operator allowed at a time). """ @@ -876,19 +876,19 @@ implements & F { a( - where: SearchByScoutConditionInputA + where: SearchByScoutRootInputA ): ID! } interface B { b( - where: SearchByScoutConditionNestedA + where: SearchByScoutRootNestedA ): ID! } interface C { c( - where: SearchByScoutConditionInputB + where: SearchByScoutRootInputB ): ID! } @@ -897,7 +897,7 @@ interface F { search: String @search - where: SearchByScoutConditionObject + where: SearchByScoutRootObject @searchBy ): Object! @all @@ -1077,7 +1077,7 @@ implements search: String @search - where: SearchByScoutConditionInputA + where: SearchByScoutRootInputA @searchBy ): ID! @all @@ -1086,7 +1086,7 @@ implements search: String @search - where: SearchByScoutConditionNestedA + where: SearchByScoutRootNestedA @searchBy ): ID! @all @@ -1095,7 +1095,7 @@ implements search: String @search - where: SearchByScoutConditionInputB + where: SearchByScoutRootInputB @searchBy ): ID! @all @@ -1104,7 +1104,7 @@ implements search: String @search - where: SearchByScoutConditionNestedB + where: SearchByScoutRootNestedB @searchBy ): ID! @all @@ -1113,7 +1113,7 @@ implements search: String @search - where: SearchByScoutConditionInputA + where: SearchByScoutRootInputA @searchBy ): ID! @all @@ -1122,7 +1122,7 @@ implements search: String @search - where: SearchByScoutConditionObject + where: SearchByScoutRootObject @searchBy ): Object! @all @@ -1131,7 +1131,7 @@ implements search: String @search - where: SearchByScoutConditionObjectInterface + where: SearchByScoutRootObjectInterface @searchBy ): ObjectInterface! @all diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/TypeRegistry.expected.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/TypeRegistry.expected.graphql index f28940047..cab04fd7e 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/TypeRegistry.expected.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/TypeRegistry.expected.graphql @@ -203,149 +203,149 @@ enum TestEnum { } """ -Available conditions for `input TestTypeA` (only one property allowed at a time). +Available operators for `enum TestEnum` (only one operator allowed at a time). """ -input SearchByConditionTestTypeA { +input SearchByEnumTestEnumOrNull { """ - All of the conditions must be true. + Equal (`=`). """ - allOf: [SearchByConditionTestTypeA!] - @searchByOperatorAllOf + equal: TestEnum + @searchByOperatorEqual """ - Any of the conditions must be true. + Within a set of values. """ - anyOf: [SearchByConditionTestTypeA!] - @searchByOperatorAnyOf + in: [TestEnum!] + @searchByOperatorIn """ - Field condition. + Is NOT NULL? """ - flag: SearchByScalarBooleanOrNull - @searchByOperatorCondition + isNotNull: SearchByTypeFlag + @searchByOperatorIsNotNull """ - Field condition. + Is NULL? """ - name: SearchByScalarStringOrNull - @searchByOperatorCondition + isNull: SearchByTypeFlag + @searchByOperatorIsNull """ - Not. + Not Equal (`!=`). """ - not: SearchByConditionTestTypeA - @searchByOperatorNot + notEqual: TestEnum + @searchByOperatorNotEqual """ - Field condition. + Outside a set of values. """ - value: SearchByEnumTestEnumOrNull - @searchByOperatorCondition + notIn: [TestEnum!] + @searchByOperatorNotIn } """ -Available conditions for `input TestTypeB` (only one property allowed at a time). -""" -input SearchByConditionTestTypeB { - """ - All of the conditions must be true. - """ - allOf: [SearchByConditionTestTypeB!] - @searchByOperatorAllOf +Conditions for the relationship (`has()`/`doesntHave()`) for `input TestTypeA`. +See also: +* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence +* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence +""" +input SearchByRelationshipRelationTestTypeA { """ - Any of the conditions must be true. + Count conditions. """ - anyOf: [SearchByConditionTestTypeB!] - @searchByOperatorAnyOf + count: SearchByScalarInt """ - Relationship condition. + Alias for `count: {greaterThanOrEqual: 1}`. Will be ignored if `count` used. """ - child: SearchByRelationshipRelationTestTypeA - @searchByOperatorRelationship + exists: Boolean """ - Field condition. + Alias for `count: {lessThan: 1}`. Will be ignored if `count` used. """ - name: SearchByScalarString - @searchByOperatorCondition + notExists: Boolean! = false """ - Not. + Additional conditions. """ - not: SearchByConditionTestTypeB - @searchByOperatorNot + where: SearchByRootTestTypeA } """ -Available operators for `enum TestEnum` (only one operator allowed at a time). +Available conditions for `input TestTypeA` (only one property allowed at a time). """ -input SearchByEnumTestEnumOrNull { +input SearchByRootTestTypeA { """ - Equal (`=`). + All of the conditions must be true. """ - equal: TestEnum - @searchByOperatorEqual + allOf: [SearchByRootTestTypeA!] + @searchByOperatorAllOf """ - Within a set of values. + Any of the conditions must be true. """ - in: [TestEnum!] - @searchByOperatorIn + anyOf: [SearchByRootTestTypeA!] + @searchByOperatorAnyOf """ - Is NOT NULL? + Field condition. """ - isNotNull: SearchByTypeFlag - @searchByOperatorIsNotNull + flag: SearchByScalarBooleanOrNull + @searchByOperatorCondition """ - Is NULL? + Field condition. """ - isNull: SearchByTypeFlag - @searchByOperatorIsNull + name: SearchByScalarStringOrNull + @searchByOperatorCondition """ - Not Equal (`!=`). + Not. """ - notEqual: TestEnum - @searchByOperatorNotEqual + not: SearchByRootTestTypeA + @searchByOperatorNot """ - Outside a set of values. + Field condition. """ - notIn: [TestEnum!] - @searchByOperatorNotIn + value: SearchByEnumTestEnumOrNull + @searchByOperatorCondition } """ -Conditions for the relationship (`has()`/`doesntHave()`) for `input TestTypeA`. - -See also: -* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence -* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence +Available conditions for `input TestTypeB` (only one property allowed at a time). """ -input SearchByRelationshipRelationTestTypeA { +input SearchByRootTestTypeB { """ - Count conditions. + All of the conditions must be true. """ - count: SearchByScalarInt + allOf: [SearchByRootTestTypeB!] + @searchByOperatorAllOf """ - Alias for `count: {greaterThanOrEqual: 1}`. Will be ignored if `count` used. + Any of the conditions must be true. """ - exists: Boolean + anyOf: [SearchByRootTestTypeB!] + @searchByOperatorAnyOf """ - Alias for `count: {lessThan: 1}`. Will be ignored if `count` used. + Relationship condition. """ - notExists: Boolean! = false + child: SearchByRelationshipRelationTestTypeA + @searchByOperatorRelationship """ - Additional conditions. + Field condition. + """ + name: SearchByScalarString + @searchByOperatorCondition + + """ + Not. """ - where: SearchByConditionTestTypeA + not: SearchByRootTestTypeB + @searchByOperatorNot } """ @@ -645,7 +645,7 @@ input SearchByTypeRangeInt { type Query { a( - where: SearchByConditionTestTypeB + where: SearchByRootTestTypeB @searchBy ): ID! @all diff --git a/packages/graphql/src/SearchBy/Operators/Child.php b/packages/graphql/src/SearchBy/Operators/Child.php index e66cbdc92..facb33fca 100644 --- a/packages/graphql/src/SearchBy/Operators/Child.php +++ b/packages/graphql/src/SearchBy/Operators/Child.php @@ -7,7 +7,7 @@ use LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\TypeProvider; use LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\TypeSource; use LastDragon_ru\LaraASP\GraphQL\Builder\Traits\HandlerOperator; -use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition; +use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition\Root; use Override; use function is_a; @@ -22,7 +22,7 @@ public static function getName(): string { #[Override] public function getFieldType(TypeProvider $provider, TypeSource $source, Context $context): string { - return $provider->getType(Condition::class, $source, $context); + return $provider->getType(Root::class, $source, $context); } #[Override] diff --git a/packages/graphql/src/SearchBy/Operators/Complex/RelationshipType.php b/packages/graphql/src/SearchBy/Operators/Complex/RelationshipType.php index 92c16bdd7..99dbff373 100644 --- a/packages/graphql/src/SearchBy/Operators/Complex/RelationshipType.php +++ b/packages/graphql/src/SearchBy/Operators/Complex/RelationshipType.php @@ -12,7 +12,7 @@ use LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\TypeSource; use LastDragon_ru\LaraASP\GraphQL\Builder\Manipulator; use LastDragon_ru\LaraASP\GraphQL\SearchBy\Directives\Directive; -use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition; +use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition\Root; use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Scalar; use Override; @@ -40,7 +40,7 @@ public function getTypeDefinition( ): TypeDefinitionNode|Type|null { $int = $manipulator->getTypeSource(Type::nonNull(Type::int())); $count = $manipulator->getType(Scalar::class, $int, $context); - $where = $manipulator->getType(Condition::class, $source, $context); + $where = $manipulator->getType(Root::class, $source, $context); return Parser::inputObjectTypeDefinition( <<getType(Condition::class, $source, $context)}!]"; + $parent = parent::getFieldType($provider, $source, $context); + $type = "[{$parent}!]"; + + return $type; } #[Override] diff --git a/packages/graphql/src/SearchBy/Operators/Logical/AnyOf.php b/packages/graphql/src/SearchBy/Operators/Logical/AnyOf.php index 6057f8c8b..184fcf061 100644 --- a/packages/graphql/src/SearchBy/Operators/Logical/AnyOf.php +++ b/packages/graphql/src/SearchBy/Operators/Logical/AnyOf.php @@ -5,7 +5,6 @@ use LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\Context; use LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\TypeProvider; use LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\TypeSource; -use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition; use Override; /** @@ -24,7 +23,10 @@ public function getFieldDescription(): string { #[Override] public function getFieldType(TypeProvider $provider, TypeSource $source, Context $context): string { - return "[{$provider->getType(Condition::class, $source, $context)}!]"; + $parent = parent::getFieldType($provider, $source, $context); + $type = "[{$parent}!]"; + + return $type; } #[Override] diff --git a/packages/graphql/src/SearchBy/Operators/Logical/Logical.php b/packages/graphql/src/SearchBy/Operators/Logical/Logical.php index e23737c14..fb824b548 100644 --- a/packages/graphql/src/SearchBy/Operators/Logical/Logical.php +++ b/packages/graphql/src/SearchBy/Operators/Logical/Logical.php @@ -12,7 +12,7 @@ use LastDragon_ru\LaraASP\GraphQL\Builder\Property; use LastDragon_ru\LaraASP\GraphQL\SearchBy\Exceptions\OperatorInvalidArgumentValue; use LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Operator; -use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition; +use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition\Root; use Nuwave\Lighthouse\Execution\Arguments\Argument; use Nuwave\Lighthouse\Execution\Arguments\ArgumentSet; use Override; @@ -24,7 +24,7 @@ abstract class Logical extends Operator { #[Override] public function getFieldType(TypeProvider $provider, TypeSource $source, Context $context): string { - return $provider->getType(Condition::class, $source, $context); + return $provider->getType(Root::class, $source, $context); } #[Override] diff --git a/packages/graphql/src/SearchBy/Operators/Root.php b/packages/graphql/src/SearchBy/Operators/Root.php index 0012cabe4..8f7a45704 100644 --- a/packages/graphql/src/SearchBy/Operators/Root.php +++ b/packages/graphql/src/SearchBy/Operators/Root.php @@ -7,7 +7,7 @@ use LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\TypeSource; use LastDragon_ru\LaraASP\GraphQL\Builder\Traits\HandlerOperator; use LastDragon_ru\LaraASP\GraphQL\Builder\Traits\WithScoutSupport; -use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition; +use LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition\Root as RootType; use Override; class Root extends Operator { @@ -21,7 +21,7 @@ public static function getName(): string { #[Override] public function getFieldType(TypeProvider $provider, TypeSource $source, Context $context): string { - return $provider->getType(Condition::class, $source, $context); + return $provider->getType(RootType::class, $source, $context); } #[Override] diff --git a/packages/graphql/src/SearchBy/Types/Condition/Condition.php b/packages/graphql/src/SearchBy/Types/Condition/Condition.php new file mode 100644 index 000000000..b71e49543 --- /dev/null +++ b/packages/graphql/src/SearchBy/Types/Condition/Condition.php @@ -0,0 +1,24 @@ +getShortName(); $typeName = $source->getTypeName(); $builderName = $context->get(HandlerContextBuilderInfo::class)?->value->getName() ?? 'Unknown'; $directiveName = Directive::Name; - return "{$directiveName}{$builderName}Condition{$typeName}"; + return "{$directiveName}{$builderName}{$name}{$typeName}"; } #[Override] diff --git a/packages/graphql/src/Stream/Directives/DirectiveTest.php b/packages/graphql/src/Stream/Directives/DirectiveTest.php index 19f349fcc..291589dfa 100644 --- a/packages/graphql/src/Stream/Directives/DirectiveTest.php +++ b/packages/graphql/src/Stream/Directives/DirectiveTest.php @@ -148,7 +148,7 @@ public function testDirective( ->graphQL( <<<'GRAPHQL' query test( - $where: SearchByConditionTestObject, + $where: SearchByRootTestObject, $order: [SortByRootTestObject!], $limit: Int!, $offset: StreamOffset, @@ -238,7 +238,7 @@ public function testDirectiveScout( <<<'GRAPHQL' query test( $search: String!, - $where: SearchByScoutConditionTestObjectSearchable, + $where: SearchByScoutRootTestObjectSearchable, $order: [SortByScoutRootTestObjectSearchable!], $limit: Int!, $offset: StreamOffset, diff --git a/packages/graphql/src/Stream/Directives/DirectiveTest~schema-expected.graphql b/packages/graphql/src/Stream/Directives/DirectiveTest~schema-expected.graphql index 6d2471c78..a8ccf43fd 100644 --- a/packages/graphql/src/Stream/Directives/DirectiveTest~schema-expected.graphql +++ b/packages/graphql/src/Stream/Directives/DirectiveTest~schema-expected.graphql @@ -135,17 +135,17 @@ enum SortByTypeDirection { """ Available conditions for `type TestObject` (only one property allowed at a time). """ -input SearchByConditionTestObject { +input SearchByRootTestObject { """ All of the conditions must be true. """ - allOf: [SearchByConditionTestObject!] + allOf: [SearchByRootTestObject!] @searchByOperatorAllOf """ Any of the conditions must be true. """ - anyOf: [SearchByConditionTestObject!] + anyOf: [SearchByRootTestObject!] @searchByOperatorAnyOf """ @@ -157,7 +157,7 @@ input SearchByConditionTestObject { """ Not. """ - not: SearchByConditionTestObject + not: SearchByRootTestObject @searchByOperatorNot } @@ -229,7 +229,7 @@ input StreamBuilder { interface InterfaceA { fieldWithArguments( argument: String - where: SearchByConditionTestObject + where: SearchByRootTestObject order: [SortByRootTestObject!] limit: Int! offset: StreamOffset @@ -249,7 +249,7 @@ implements interface InterfaceC { fieldWithDirectives( - a: SearchByConditionTestObject + a: SearchByRootTestObject b: [SortByRootTestObject!] c: Int! d: StreamOffset @@ -299,7 +299,7 @@ implements @validate fieldNotSortable( - where: SearchByConditionTestObject + where: SearchByRootTestObject @searchBy """ @@ -325,7 +325,7 @@ implements fieldWithArguments( argument: String - where: SearchByConditionTestObject + where: SearchByRootTestObject @searchBy order: [SortByRootTestObject!] @@ -350,7 +350,7 @@ implements @validate fieldWithDeprecations( - a: SearchByConditionTestObject + a: SearchByRootTestObject @deprecated @searchBy @@ -378,7 +378,7 @@ implements @deprecated @streamOffset - where: SearchByConditionTestObject + where: SearchByRootTestObject @searchBy order: [SortByRootTestObject!] @@ -407,7 +407,7 @@ implements @validate fieldWithDirectives( - a: SearchByConditionTestObject + a: SearchByRootTestObject @searchBy b: [SortByRootTestObject!] @@ -435,7 +435,7 @@ implements @validate fieldWithDirectivesAndDefaults( - a: SearchByConditionTestObject + a: SearchByRootTestObject @searchBy b: [SortByRootTestObject!] @@ -464,7 +464,7 @@ implements @validate fieldWithoutArguments( - where: SearchByConditionTestObject + where: SearchByRootTestObject @searchBy order: [SortByRootTestObject!] diff --git a/packages/graphql/src/Stream/Directives/DirectiveTest~scout-expected.graphql b/packages/graphql/src/Stream/Directives/DirectiveTest~scout-expected.graphql index 164a4b1ba..8b12ea00b 100644 --- a/packages/graphql/src/Stream/Directives/DirectiveTest~scout-expected.graphql +++ b/packages/graphql/src/Stream/Directives/DirectiveTest~scout-expected.graphql @@ -111,11 +111,11 @@ enum SortByTypeDirection { """ Available conditions for `type TestObject` (only one property allowed at a time). """ -input SearchByScoutConditionTestObject { +input SearchByScoutRootTestObject { """ All of the conditions must be true. """ - allOf: [SearchByScoutConditionTestObject!] + allOf: [SearchByScoutRootTestObject!] @searchByOperatorAllOf """ @@ -181,7 +181,7 @@ input StreamBuilder { interface InterfaceA { fieldWithSearch( argument: String - where: SearchByScoutConditionTestObject + where: SearchByScoutRootTestObject order: [SortByScoutRootTestObject!] limit: Int! offset: StreamOffset @@ -209,7 +209,7 @@ implements search: String! @search - where: SearchByScoutConditionTestObject + where: SearchByScoutRootTestObject @searchBy order: [SortByScoutRootTestObject!]