-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(graphql): Support of
extend scalar/etc X
to add operators.
(cherry picked from commit a9dd684)
- Loading branch information
1 parent
406f5d5
commit c7bd1c4
Showing
5 changed files
with
285 additions
and
3 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
219 changes: 219 additions & 0 deletions
219
packages/graphql/src/SearchBy/Directives/DirectiveTest~scalars-expected.graphql
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,219 @@ | ||
""" | ||
Use Input as Search Conditions for the current Builder. | ||
""" | ||
directive @searchBy | ||
on | ||
| ARGUMENT_DEFINITION | ||
|
||
directive @searchByOperatorAllOf | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorEqual | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorIn | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorIsNotNull | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorIsNull | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorLessThan | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorLessThanOrEqual | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorNotEqual | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
directive @searchByOperatorProperty | ||
on | ||
| ENUM | ||
| INPUT_FIELD_DEFINITION | ||
| SCALAR | ||
|
||
""" | ||
Extends the list of operators by the operators from the specified `type`. | ||
""" | ||
directive @searchByOperators( | ||
type: String! | ||
) | ||
on | ||
| ENUM | ||
| SCALAR | ||
|
||
enum EnumA | ||
@searchByOperatorIn | ||
{ | ||
A | ||
} | ||
|
||
enum SearchByTypeFlag { | ||
yes | ||
} | ||
|
||
""" | ||
Available conditions for `input A` (only one property allowed at a time). | ||
""" | ||
input SearchByConditionA { | ||
""" | ||
Property condition. | ||
""" | ||
a: SearchByScalarMixed | ||
@searchByOperatorProperty | ||
|
||
""" | ||
All of the conditions must be true. | ||
""" | ||
allOf: [SearchByConditionA!] | ||
@searchByOperatorAllOf | ||
|
||
""" | ||
Property condition. | ||
""" | ||
b: SearchByScalarDateOrNull | ||
@searchByOperatorProperty | ||
|
||
""" | ||
Property condition. | ||
""" | ||
c: SearchByEnumEnumAOrNull | ||
@searchByOperatorProperty | ||
} | ||
|
||
""" | ||
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). | ||
""" | ||
input SearchByScalarDateOrNull { | ||
""" | ||
Equal (`=`). | ||
""" | ||
equal: Date | ||
@searchByOperatorEqual | ||
|
||
""" | ||
Is NOT NULL? | ||
""" | ||
isNotNull: SearchByTypeFlag | ||
@searchByOperatorIsNotNull | ||
|
||
""" | ||
Is NULL? | ||
""" | ||
isNull: SearchByTypeFlag | ||
@searchByOperatorIsNull | ||
|
||
""" | ||
Less than (`<`). | ||
""" | ||
lessThan: Date | ||
@searchByOperatorLessThan | ||
|
||
""" | ||
Less than or equal to (`<=`). | ||
""" | ||
lessThanOrEqual: Date | ||
@searchByOperatorLessThanOrEqual | ||
|
||
""" | ||
Not Equal (`!=`). | ||
""" | ||
notEqual: Date | ||
@searchByOperatorNotEqual | ||
} | ||
|
||
""" | ||
Available operators for `scalar Mixed` (only one operator allowed at a time). | ||
""" | ||
input SearchByScalarMixed { | ||
""" | ||
Equal (`=`). | ||
""" | ||
equal: Mixed | ||
@searchByOperatorEqual | ||
|
||
""" | ||
Not Equal (`!=`). | ||
""" | ||
notEqual: Mixed | ||
@searchByOperatorNotEqual | ||
} | ||
|
||
scalar Date | ||
@scalar( | ||
class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\Date" | ||
) | ||
@searchByOperators( | ||
type: "Boolean" | ||
) | ||
@searchByOperatorLessThan | ||
@searchByOperatorLessThanOrEqual | ||
|
||
""" | ||
The `String` scalar type represents textual data, represented as UTF-8 | ||
character sequences. The String type is most often used by GraphQL to | ||
represent free-form human-readable text. | ||
""" | ||
scalar Mixed | ||
@scalar( | ||
class: "GraphQL\\Type\\Definition\\StringType" | ||
) | ||
@searchByOperatorEqual | ||
|
||
type Query { | ||
test( | ||
where: SearchByConditionA | ||
@searchBy | ||
): ID! | ||
@all | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/graphql/src/SearchBy/Directives/DirectiveTest~scalars.graphql
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,31 @@ | ||
type Query { | ||
test(where: A @searchBy): ID! @all | ||
} | ||
|
||
input A { | ||
a: Mixed! | ||
b: Date | ||
c: EnumA | ||
} | ||
|
||
scalar Date | ||
@scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\Date") | ||
@searchByOperators(type: "Boolean") | ||
@searchByOperatorLessThan | ||
@searchByOperatorLessThanOrEqual | ||
|
||
enum EnumA | ||
@searchByOperatorIn | ||
{ | ||
A | ||
} | ||
|
||
scalar SearchByExtra | ||
@searchByOperatorAllOf | ||
|
||
scalar Mixed | ||
@scalar(class: "GraphQL\\Type\\Definition\\StringType") | ||
@searchByOperatorEqual | ||
|
||
extend scalar Mixed | ||
@searchByOperatorNotEqual |
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