Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@searchBy Polymorphic relationship support #221

Open
Orrison opened this issue Jan 28, 2025 · 1 comment
Open

@searchBy Polymorphic relationship support #221

Orrison opened this issue Jan 28, 2025 · 1 comment
Labels
pkg: graphql scope: feat New feature or request

Comments

@Orrison
Copy link

Orrison commented Jan 28, 2025

Hello! Thank you so much for the development and maintenance of this package. It works great and the care you put into it is deeply appreciated.

I wanted to ask if there is currently support for querying of Polymorphic relationships with @searchBy through some syntax we are not finding apparent.
When we first adopted this package we couldn't work out how to get a MorphTo relationship to work for example, so we created a custom directive for this to work but it seems recent updates may have caused issues.

Here is an example of an entity with a MorphTo relationship: https://github.com/canyongbs/advisingapp/blob/main/app-modules/alert/graphql/alert.graphql

And our custom directive: https://github.com/canyongbs/advisingapp/blob/main/app/GraphQL/Directives/MorphToRelationDirective.php

Any guidance you can provide on how to best make the queries work would be very appreciated.

Thank you so much!

@LastDragon-ru
Copy link
Owner

LastDragon-ru commented Jan 29, 2025

Thanks you.

I wanted to ask if there is currently support for querying of Polymorphic relationships with @searchby through some syntax we are not finding apparent.

Unfortunately, there is no support. It is also not on my todo list (I thought about it, but have no idea how to assign models class names in graphql).

When we first adopted this package we couldn't work out how to get a MorphTo relationship to work for example, so we created a custom directive for this to work but it seems recent updates may have caused issues.

What version are you using? Seems below v6? The v6 introduced new syntax. You can restore old as described in upgrade guide1.
There were also few interface changes (moving/renames), probably you just need update you code accordingly. Please refer to upgrade guide and also you can search refactor(graphql) in commits.

# >= v6
users(where: { 
  field: { name: { equal: "..." } } 
}

# <= v5
where: { 
  name: { equal: "..." } 
}

Footnotes

  1. Actually v5 syntax can be restored in (upcoming) v8 too, but the \LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Condition\V5::class was removed from the package, so you need to copy it into your app and use/bind it.

@LastDragon-ru LastDragon-ru added scope: feat New feature or request pkg: graphql labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: graphql scope: feat New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants