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

Multiple @where directives on a single field #831

Closed
cwhitby opened this issue Jun 12, 2019 · 5 comments
Closed

Multiple @where directives on a single field #831

cwhitby opened this issue Jun 12, 2019 · 5 comments
Labels
5.x Related to the 5.x release series enhancement A feature or improvement

Comments

@cwhitby
Copy link
Contributor

cwhitby commented Jun 12, 2019

Is your feature request related to a problem? Please describe.

It would be great if we could apply multiple @where directives to a single field.
For example:

input AuditFilterInput {
    date_after: Date @where(operator: ">=", key: "date") @where(operator: ">=", clause: "orWhere", key: "created_at")
}

In this case, only the first directive is applied.

Describe the solution you'd like

I can think of 3 options:

A) Allow multiple instances of the @where directive. I don't think any other directive allows this either so there might be a limitation in the core of Lighthouse.

B) Allow the @where directive to accept an array of conditions, in a similar format to how the Laravel Query Builder does.

C) This behaviour already exists somewhere and I just can't see it in the docs.

Curious to see what others think.

@spawnia
Copy link
Collaborator

spawnia commented Jun 12, 2019

Have you actually tried this in the most recent version of Lighthouse? I agree that this should work.

@cwhitby
Copy link
Contributor Author

cwhitby commented Jun 12, 2019

It was originally tested using version 3.7.0, I've just checked again using 4.0-alpha.2 with the same result.

@spawnia
Copy link
Collaborator

spawnia commented Jun 12, 2019

Can you provide a PR with a failing test case in https://github.com/nuwave/lighthouse/blob/master/tests/Integration/Execution/BuilderTest.php please?

@spawnia spawnia added the enhancement A feature or improvement label Jun 20, 2019
@spawnia
Copy link
Collaborator

spawnia commented Jun 20, 2019

We can enable this feature (and possibly other use cases of applying the same directive repeatedly) once the spec allows it: graphql/graphql-spec#472

@spawnia
Copy link
Collaborator

spawnia commented Jul 20, 2020

Changed handling of the argument filters makes this work for @where now, at least #834 passed for now.

General availability and proper documentation of repeatable directives will be tracked in #1133.

Feel free to reopen if you still experience issues.

@spawnia spawnia closed this as completed Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.x Related to the 5.x release series enhancement A feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants