Skip to content

Commit

Permalink
deprecate(graphql/@searchBy): @searchByOperatorRelation, the `@se…
Browse files Browse the repository at this point in the history
…archByOperatorRelationship` should be used instead.

Partially reverts 0574fd2
  • Loading branch information
LastDragon-ru committed Mar 1, 2024
1 parent ce67672 commit 8cdb50e
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/graphql/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)

* [ ] `@searchByOperators` => `@searchByExtendOperators`. 🤝

* [ ] `@searchByOperatorRelation` => `@searchByOperatorRelationship` (and class too; generated types will be named as `SearchByRelationship*` instead of `SearchByComplex*`).
* [ ] `@searchByOperatorRelation` => `@searchByOperatorRelationship` (and class too; generated types will be named as `SearchByRelationship*` instead of `SearchByComplex*`). 🤝

* [ ] `LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators::Condition` => `LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators::Object`.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\GraphQL\SearchBy\Definitions;

use LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Complex\Relationship;

/**
* @deprecated 5.6.0 Please use {@see SearchByOperatorRelationshipDirective}.
*/
class SearchByOperatorRelationDirective extends Relationship {
// Lighthouse loads all classes from directive namespace this leads to
// 'Class "Orchestra\Testbench\TestCase" not found' error for our *Test
// classes. This class required to avoid this error.
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ on
| INPUT_FIELD_DEFINITION
| SCALAR

directive @searchByOperatorRelation
on
| FIELD_DEFINITION
| INPUT_FIELD_DEFINITION
| SCALAR

directive @searchByOperatorRelationship
on
| FIELD_DEFINITION
Expand All @@ -189,14 +195,6 @@ enum SearchByTypeFlag {
)
}

input Comment {
date: Date
text: String!

user: User
@belongsTo
}

"""
Available conditions for `input CommentsQuery` (only one field allowed at a time).
"""
Expand Down Expand Up @@ -271,6 +269,12 @@ input SearchByConditionUser {
"""
not: SearchByConditionUser
@searchByOperatorNot

"""
Relationship condition.
"""
parent: SearchByRelationshipUser
@searchByOperatorRelation
}

"""
Expand Down Expand Up @@ -308,6 +312,35 @@ input SearchByConditionUsersQuery {
@searchByOperatorNot
}

"""
Conditions for the relationship (`has()`/`doesntHave()`) for `type User`.
See also:
* https://laravel.com/docs/eloquent-relationships#querying-relationship-existence
* https://laravel.com/docs/eloquent-relationships#querying-relationship-absence
"""
input SearchByRelationshipUser {
"""
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: SearchByConditionUser
}

"""
Conditions for the relationship (`has()`/`doesntHave()`) for `input UsersQuery`.
Expand Down Expand Up @@ -630,6 +663,14 @@ scalar Date
class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\Date"
)

type Comment {
date: Date
text: String!

user: User
@belongsTo
}

type Query {
comments(
where: SearchByConditionCommentsQuery
Expand All @@ -647,4 +688,7 @@ type Query {
type User {
id: ID!
name: String!

parent: User
@searchByOperatorRelation
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ input CommentsQuery {
type User {
id: ID!
name: String!
parent: User
@searchByOperatorRelation
}

input Comment {
type Comment {
text: String!
user: User @belongsTo
date: Date
Expand Down

0 comments on commit 8cdb50e

Please sign in to comment.